You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by David Farb <dm...@chicagonet.net> on 2003/12/25 16:11:14 UTC

[log] [config] Configure log4j to files

My compliments and thanks to all who have worked on Geronimo so far.
I hope to become a useful contributor. So here is my first one.

I didn't find this anywhere on the wiki, or in the archives,
so I built a log4j.properties and a maven modification to send the
Geronimo logs to a file directory. Suggestions for improvement are
welcome and encouraged. I will put this in the wiki if I recieve
no updates after a week or so.

1. In the maven.xml for the run:main and the debug:main goals, add
the system property logs.home (I didn't want to change geronimo.home,
and the file: prefix messes things up.):

	...
     <sysproperty key="geronimo.home" value="file:${run.dir}/"/>
     <sysproperty key="logs.home" value="${run.dir}"/>
	...

The property ${logs.home} is picked up in the log4j.properties file and
allows you to NOT hardcode the directory.

2. Manually create a "logs" directory in target/geronimo-DEV. It would be
nice if this were not necessary, but...

3. Modify the target/geronimo-DEV/etc/log4j.properties (run time) and the
modules/kernel/src/conf/log4j.properties (CVS'd) files as follows: (I left
the CONSOLE definition in, it doesn't hurt and provides documentation.)

(I vote for flat file configuration, at least then you can document what you
have done and why you have done it. If you feel inclined.)


##
## Log4j Configuration
##
## $Revision: 1.2 $ $Date: 2003/11/06 20:56:31 $
##

log4j.rootCategory=TRACE#org.apache.geronimo.kernel.log.XLevel, LOGFILE

# CONSOLE logger definition
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=TRACE#org.apache.geronimo.kernel.log.XLevel
#log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}]
%m%n


# LOGFILE Logger Definintion
#
# Use a RollingFileAppender to minimize the file size.
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender

# The following requires the manual creating of a logs
# subdirectory in target/gernonimo-DEV

log4j.appender.LOGFILE.File=${logs.home}/logs/geronimo.log

# Theoretically this rewites the file every time. Set Append to true if
# you want a cumulative log.
log4j.appender.LOGFILE.Append=false

# Don't buffer log I/O. This is the default, but document, document, ...
log4j.appender.LOGFILE.BufferedIO=false
log4j.appender.LOGFILE.MaxFileSize=1MB
log4j.appender.LOGFILE.MaxBackupIndex=1
log4j.appender.LOGFILE.Threshold=TRACE#org.apache.geronimo.kernel.log.XLevel
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}]
%m%n


# Geronimo and other flags
log4j.logger.org.apache.commons.beanutils=INFO
log4j.logger.org.apache.commons.digester=INFO
log4j.logger.org.apache.geronimo.kernel.deployment.scanner=INFO