Below is the order in which c.t.l picks up loggers: 1. SLF4j (which also includes Logback, since it natively implements the SLF4j API) 2. Apache Commons-logging 3. Log4j 4. java.util.logging
Reference: https://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging/impl.clj#L214 Both #1 and #2 are merely logger facade, incapable of logging anywhere except to the console by themselves. They need an underlying logger for real-world logging. Your dependencies only include the SLF4j-log4j bridge (without the log4j dependency), which I am not sure is supposed to be picked up by c.t.l. I would suggest either remove slf4j-log4j dependency altogether (allowing j.u.l to be chosen) or add the slf4j [org.slf4j/slf4j-api "1.7.13"] and log4j [log4j/log4j "1.2.17"] dependencies to your current config. Hope this helps. Shantanu On Wednesday, 16 December 2015 23:47:39 UTC+5:30, Mayank Jain wrote: > > Thanks Shantanu for your reply, > > It still didn't work. > > Here's my project.clj > (defproject log "0.1.0-SNAPSHOT" > :description "FIXME: write description" > :url "http://example.com/FIXME" > :license {:name "Eclipse Public License" > :url "http://www.eclipse.org/legal/epl-v10.html"} > :dependencies [[org.clojure/clojure "1.7.0"] > [org.clojure/tools.logging "0.3.1"] > [org.slf4j/slf4j-log4j12 "1.7.13"]]) > > > And here's my resources/log4j.properties file > # Root logger option > log4j.rootLogger=INFO, stdout > > # Direct log messages to stdout > log4j.appender.stdout=org.apache.log4j.ConsoleAppender > log4j.appender.stdout.Target=System.out > log4j.appender.stdout.layout=org.apache.log4j.PatternLayout > log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} > %-5p %c{1}:%L - %m%n > > And here's my the output from my Clojure repl in Emacs: > user> (require '[clojure.tools.logging :as ctl]) > nil > user> (ctl/error "Fail!") > nil > > And here's what I get on my console > $ lein repl :headless :port 4005 > nREPL server started on port 4005 on host 127.0.0.1 - nrepl:// > 127.0.0.1:4005 > 2015-12-16 23:44:50 ERROR user:288 - Fail! > > I would like it to print the same on both Emacs repl and on console (and > add to a file). > > I can get it to write on console and file but not on repl. > > On Wednesday, December 16, 2015 at 10:13:12 PM UTC+5:30, Shantanu Kumar > wrote: >> >> If you enabled Log4j console logger, the logs should appear in the REPL >> too. >> >> See example at >> http://www.mkyong.com/logging/log4j-log4j-properties-examples/ >> >> You do not necessarily need log4j to log to the REPL via >> clojure.tools.logging - you can just use c.t.l. without any logging library >> and it will fall back to java.util.logging using STDOUT. >> >> Shantanu >> >> On Wednesday, 16 December 2015 21:58:40 UTC+5:30, Mayank Jain wrote: >>> >>> Hi, >>> >>> I would like to be able to print log statements >>> via clojure.tools.logging to print on clojure repl as well. >>> I am using log4j logging framework for configurations. >>> Is this possible? I am unable to figure it out. >>> I am open to any other logging framework if that solves this. >>> >>> Thanks. >>> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.