You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rainer juenger <ja...@projektinter.net> on 2002/07/17 15:09:36 UTC

Problem setting up logging with log4j and commons-logging

Hi,

I am having some probs with setting up the logging with commons-logging and log4j used in struts.

1) I placed the commons-logging.jar and the log4j.jar in the common/lib directory of my tomcat 4.01.
2) placed my commons-logging.properties file within the WEB-INF/classes directory of my application. I expect getting a file (named in the commons-logging.properties - file e.g. mylog.txt) mylog.txt in the WEB-INF/classes.
3) the commons-logging.properties file I am using is the log4j.properties file that comes with the package.

logging ist not working somehow no file is written. But I am getting no exceptions.

thanks, Rainer



Please don't just say read:
http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/package-summary.html
I did it many many times alread!

Here is the:

# An example log4j configuration file that outputs both to System.out
# and a file named 'test'.

# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.

# WARNING: Location information can be useful but is very costly in
# terms of computation.

# The root logger uses the appender called A1. 

# The root logger uses the appenders called A1 and A2. Since no level
# is specified, note the empty string between the comma (",") and the
# equals sign ("="), the level of the root logger remains
# untouched. Log4j always initializes the level for the root logger to
# DEBUG. The root logger is the only logger that has a default
# level. Bu default, all other loggers do not have an assigned level,
# such that they inherit their level instead.

log4j.rootLogger=, A1, A2

# A1 is set to be ConsoleAppender sending its output to System.out
log4j.appender.A1=org.apache.log4j.ConsoleAppender


# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# The conversion pattern consists of date in ISO8601 format, level,
# thread name, logger name truncated to its rightmost two components
# and left justified to 17 characters, location information consisting
# of file name (padded to 13 characters) and line number, nested
# diagnostic context, the and the application supplied message

log4j.appender.A1.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n

# Appender A2 writes to the file "test".
log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=applog.txt

# Truncate 'test' if it aleady exists.
log4j.appender.A2.Append=false

# Appender A2 uses the PatternLayout.
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5r %-5p [%t] %c{2} - %m%n


# In this example, we are not interested in INNER loop or SWAP
# messages.  You might try to set INNER and SWAP to DEBUG for more
# verbose output.

log4j.logger.org.apache.log4j.examples.SortAlgo.INNER=INFO
log4j.logger.org.apache.log4j.examples.SortAlgo.SWAP=INFO