You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Dunbar, Kevin D CIV SPAWARSYSCEN-PACIFIC, 56250" <ke...@navy.mil> on 2012/07/07 01:08:10 UTC

log4j to write Tomcat logs to Windows Event Log

Hi,
 
I am trying to use log4j.jar to do the logging in Tomcat 7.0.27 (on Windows XP) instead of java.util.logging so that I can append the logs to be output to the Windows Event Log.
 
I followed the instructions to configure Tomcat to use log4j rather than java.util.logging for all Tomcat's internal logging.  (http://tomcat.apache.org/tomcat-7.0-doc/logging.html)
 
I created a log4j.properties file and put it in $CATALINA_BASE/lib
I put log4j-1.2.15.jar that I downloaded into $CATALINA_HOME/lib
I put tomcat-juli-adapters.jar that I downloaded into $CATALINA_HOME/lib
I replaced tomcat-juli.jar from $CATALINA_HOME with the tomcat-juli.jar that I downloaded from Tomcat "extras"
 
It seems that after I replaced the tomcat-juli.jar, I would get the following error in tomcat7-stderr.log
 
2012-07-06 14:03:56 Commons Daemon procrun stderr initialized
log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.Catalina).
log4j:WARN Please initialize the log4j system properly.
 
I also deleted the logging.properties from $CATALINA_BASE/conf
 
Can anyone please tell me why this warning is occurring when I replace tomcat-juli.jar?  Any help is greatly appreciated.
 
 
Kevin Dunbar
Code 56250
SPAWAR Systems Center Pacific
(619) 553-0777
kevin.dunbar@navy.mil

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: log4j to write Tomcat logs to Windows Event Log

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin,

On 7/9/12 11:52 AM, Dunbar, Kevin D CIV SPAWARSYSCEN-PACIFIC, 56250 wrote:
> Thank you Chris and Konstantin for replying to my message. Here is
>  the contents of the log4j.properties file... (This was taken from
> the instructions on the Tomcat website for logging with log4j).
> Thank you again for any help you can provide.
> 
> log4j.rootLogger=INFO, CATALINA # Define all the appenders 
> log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender 
> log4j.appender.CATALINA.File=${catalina.base}/logs/catalina. 
> log4j.appender.CATALINA.Append=true 
> log4j.appender.CATALINA.Encoding=UTF-8

That looks okay to me, except that I didn't realize that
$CATALINA_BASE/lib would load JAR files contained in it as well as raw
resources, but you are following the documentation faithfully.

Try setting the "-Dlog4j.debug" system property (no specific value is
necessary) and log4j should spew a lot of stuff to stdout that you can
see when it is performing its configuration -- you'll be able to see
when it first initializes and what happens at that time.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/8WHAACgkQ9CaO5/Lv0PCUdgCgqLRF2DZ5DLZQSZQTx8OIm4ve
+2kAnRMAv7w7iUHHIcT5JDdh2Y0BA1tb
=0B8R
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: log4j to write Tomcat logs to Windows Event Log

Posted by "Dunbar, Kevin D CIV SPAWARSYSCEN-PACIFIC, 56250" <ke...@navy.mil>.
Thank you Chris and Konstantin for replying to my message.  Here is the contents of the log4j.properties file...
(This was taken from the instructions on the Tomcat website for logging with log4j).  Thank you again for any help you can provide.
 
 
 
log4j.rootLogger=INFO, CATALINA
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.
log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.LOCALHOST=org.apache.log4j.DailyRollingFileAppender
log4j.appender.LOCALHOST.File=${catalina.base}/logs/localhost.
log4j.appender.LOCALHOST.Append=true
log4j.appender.LOCALHOST.Encoding=UTF-8
log4j.appender.LOCALHOST.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.LOCALHOST.layout = org.apache.log4j.PatternLayout
log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.MANAGER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.MANAGER.File=${catalina.base}/logs/manager.
log4j.appender.MANAGER.Append=true
log4j.appender.MANAGER.Encoding=UTF-8
log4j.appender.MANAGER.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.MANAGER.layout = org.apache.log4j.PatternLayout
log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.HOST-MANAGER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.HOST-MANAGER.File=${catalina.base}/logs/host-manager.
log4j.appender.HOST-MANAGER.Append=true
log4j.appender.HOST-MANAGER.Encoding=UTF-8
log4j.appender.HOST-MANAGER.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.HOST-MANAGER.layout = org.apache.log4j.PatternLayout
log4j.appender.HOST-MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Encoding=UTF-8
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
# Configure which loggers log to which appenders
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO, LOCALHOST
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]=\
  INFO, MANAGER
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]=\
  INFO, HOST-MANAGER

 
 
 
Kevin Dunbar
Code 56250
SPAWAR Systems Center Pacific
(619) 553-0777
kevin.dunbar@navy.mil

________________________________

From: Christopher Schultz [mailto:chris@christopherschultz.net]
Sent: Sun 7/8/2012 9:33 AM
To: Tomcat Users List
Subject: Re: log4j to write Tomcat logs to Windows Event Log



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Konstantin,

On 7/8/12 5:40 AM, Konstantin Kolinko wrote:
> Your log4j.properties is wrong?

+1

Kevin, can you post your log4j.properties file?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org <http://gpgtools.org/> 
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/5tm4ACgkQ9CaO5/Lv0PBt8gCfaGjSj3MVwx6u8JtTu6AEUP3F
/6cAoJD3RAl01y6N2PxS8X/9FeZ1/Ax8
=+OEK
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: log4j to write Tomcat logs to Windows Event Log

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Konstantin,

On 7/8/12 5:40 AM, Konstantin Kolinko wrote:
> Your log4j.properties is wrong?

+1

Kevin, can you post your log4j.properties file?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/5tm4ACgkQ9CaO5/Lv0PBt8gCfaGjSj3MVwx6u8JtTu6AEUP3F
/6cAoJD3RAl01y6N2PxS8X/9FeZ1/Ax8
=+OEK
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: log4j to write Tomcat logs to Windows Event Log

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/7/7 Dunbar, Kevin D CIV SPAWARSYSCEN-PACIFIC, 56250
<ke...@navy.mil>:
> Hi,
>
> I am trying to use log4j.jar to do the logging in Tomcat 7.0.27 (on Windows XP) instead of java.util.logging so that I can append the logs to be output to the Windows Event Log.
>
> I followed the instructions to configure Tomcat to use log4j rather than java.util.logging for all Tomcat's internal logging.  (http://tomcat.apache.org/tomcat-7.0-doc/logging.html)
>
> I created a log4j.properties file and put it in $CATALINA_BASE/lib
> I put log4j-1.2.15.jar that I downloaded into $CATALINA_HOME/lib
> I put tomcat-juli-adapters.jar that I downloaded into $CATALINA_HOME/lib
> I replaced tomcat-juli.jar from $CATALINA_HOME with the tomcat-juli.jar that I downloaded from Tomcat "extras"
>
> It seems that after I replaced the tomcat-juli.jar, I would get the following error in tomcat7-stderr.log
>
> 2012-07-06 14:03:56 Commons Daemon procrun stderr initialized
> log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.Catalina).
> log4j:WARN Please initialize the log4j system properly.

Your log4j.properties is wrong?
It looks like it does not specify where the messages from
"org.apache.catalina.startup.Catalina" log category should be written.

> I also deleted the logging.properties from $CATALINA_BASE/conf

One should not delete the file itself, but only its contents, leaving
an empty file.

> Can anyone please tell me why this warning is occurring when I replace tomcat-juli.jar?  Any help is greatly appreciated.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: log4j to write Tomcat logs to Windows Event Log

Posted by sandy <sa...@gmail.com>.
Hello, 

Did you install Tomcat as a Windows service using the installer for windows?
If that's the case, review your configuration. The same occurred to me and I
solved it by configuring the service. Right-click on tomcat icon at the
systray and then click on "Configure...". In the "Java" tab, in the field
"Java Options", I have the following properties defined:

...
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat
7.0\endorsed
...
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Program Files\Apache Software
Foundation\Tomcat 7.0\lib\log4j.properties
...

Finally, I created the C:\Program Files\Apache Software Foundation\Tomcat
7.0\endorsed because I didn't exist and then I copied log4j.jar inside it.
By doing this, the warning message disappeared, at least that was my case.

I hope my solution works for you as well. Good luck. 
  Sandy




--
View this message in context: http://tomcat.10.n6.nabble.com/log4j-to-write-Tomcat-logs-to-Windows-Event-Log-tp4983672p4984394.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org