loggingclojurelog4jclojure-contrib

clojure contrib logging to file


Hi I have tried logging with clojure contrib but to no avail. Its clojure 1.1

(ns com.class.main.service
 (:gen-class)
 (:require (clojure.contrib [logging :as log])))

(log/info "Hello world")

I have put a log4j.jar file in my bin and a log4j.properties in the same directory as the log4j.jar.

Below is the log4j.properties conifguration

log4j.rootLogger=INFO, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=H:\\log\\loging.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L -  %m%n*

I have gone through some basic examples although they are limited due to most using the newer version with tool.logging.

But below are the examples i have used

https://github.com/macourtney/Conjure/wiki/How-to-use-logging & http://www.paullegato.com/blog/setting-clojure-log-level/ have helped me get this far the log prints out on the console of emacs but i can't find a log file anywhere.


Solution

  • CLojure logging has three options commons-logging, log4j-logging, java-logging and it picks them in that order according to availability as per the document specification . After looking at my sources it showed the same however the compiled version was a completley different order it started with java-logging. So I simply recompiled my contrib with ant to match the order i required as i couldn't remove java-logging.