You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Nikolay Georgiev <ng...@gistec-online.de> on 2006/04/13 19:47:46 UTC

[Commons Logging] Tomcat - Don't write to the File

Hello,

I've adjusted the my web application on Tomcat to use commons logging, but
somehow the size of the file in which it should write is always 0kb. Though,
the last modified time of this file is always updated, when something is
logged.

So I have a Start-up-Servlet who loads the absolute filePath into a
variable(log4jConfigFile) and then I call the
PropertyConfigurator.configure(log4jConfigFile);.

Every Class has it's own log file initialized like
private static Log log = LogFactory.getLog(myclass.class);


The Config File looks like that:
========================================= Config file
# --------------------------------------------------------------------------
---
# Root-Logger settings - INFO should be selected to see Importoutput
# --------------------------------------------------------------------------
---
log4j.rootLogger = DEBUG, default, ImportLogFile

# --------------------------------------------------------------------------
---
# Logging to console with Default-Logger
# --------------------------------------------------------------------------
---
log4j.appender.default = org.apache.log4j.ConsoleAppender
log4j.appender.default.layout = org.apache.log4j.PatternLayout
log4j.appender.default.layout.conversionPattern = %m%n

# --------------------------------------------------------------------------
---
# Loggin to file with ImportLogFile-Logger
# --------------------------------------------------------------------------
---
log4j.appender.ImportLogFile = org.apache.log4j.FileAppender
log4j.appender.ImportLogFile.file = d:/import.log
log4j.appender.ImportLogFile.append = false
log4j.appender.ImportLogFile.layout = org.apache.log4j.PatternLayout
log4j.appender.ImportLogFile.layout.conversionPattern = %d [%t] %-5p %c %n
%m%n

========================================= Config file END


So it writes to the file d:/import.log, and this file is always 0kb, but by
looking at the last modified date of the file, I see that it's always
accessed when log operation is executed.

Does anyone have an idea, why nothing is written to the file?

I'm using
Tomcat 5.0
WEB-INF/lib/commons-logging-1.0.2.jar
WEB-INF/lib/log4j-1.2.8.jar



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [Commons Logging] Tomcat - Don't write to the File

Posted by Nikolay Georgiev <ng...@gistec-online.de>.
Problem solved :)

With Eclipse the Logger of Apache was choosen, but with Tomcat the Logger of
SUN.
So by adding into WEB-INF/classes the file commons-logging.properties,
containing:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategory
Log

chooses automatically the logger of Apache, which works fine, and writes to
the file.



-----Ursprüngliche Nachricht-----
Von: Nikolay Georgiev [mailto:ngeorgiev@gistec-online.de]
Gesendet: Donnerstag, 13. April 2006 19:48
An: commons-user@jakarta.apache.org
Betreff: [Commons Logging] Tomcat - Don't write to the File


Hello,

I've adjusted the my web application on Tomcat to use commons logging, but
somehow the size of the file in which it should write is always 0kb. Though,
the last modified time of this file is always updated, when something is
logged.

So I have a Start-up-Servlet who loads the absolute filePath into a
variable(log4jConfigFile) and then I call the
PropertyConfigurator.configure(log4jConfigFile);.

Every Class has it's own log file initialized like
private static Log log = LogFactory.getLog(myclass.class);


The Config File looks like that:
========================================= Config file
# --------------------------------------------------------------------------
---
# Root-Logger settings - INFO should be selected to see Importoutput
# --------------------------------------------------------------------------
---
log4j.rootLogger = DEBUG, default, ImportLogFile

# --------------------------------------------------------------------------
---
# Logging to console with Default-Logger
# --------------------------------------------------------------------------
---
log4j.appender.default = org.apache.log4j.ConsoleAppender
log4j.appender.default.layout = org.apache.log4j.PatternLayout
log4j.appender.default.layout.conversionPattern = %m%n

# --------------------------------------------------------------------------
---
# Loggin to file with ImportLogFile-Logger
# --------------------------------------------------------------------------
---
log4j.appender.ImportLogFile = org.apache.log4j.FileAppender
log4j.appender.ImportLogFile.file = d:/import.log
log4j.appender.ImportLogFile.append = false
log4j.appender.ImportLogFile.layout = org.apache.log4j.PatternLayout
log4j.appender.ImportLogFile.layout.conversionPattern = %d [%t] %-5p %c %n
%m%n

========================================= Config file END


So it writes to the file d:/import.log, and this file is always 0kb, but by
looking at the last modified date of the file, I see that it's always
accessed when log operation is executed.

Does anyone have an idea, why nothing is written to the file?

I'm using
Tomcat 5.0
WEB-INF/lib/commons-logging-1.0.2.jar
WEB-INF/lib/log4j-1.2.8.jar



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org