permaculture playing cards*
The moose likes Tomcat and the fly likes Simple logging config? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Simple logging config?" Watch "Simple logging config?" New topic
Author

Simple logging config?

Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

Hello,

I'm looking for a simple logging config. I would like to use slf4j. I consider log4j overkill for what I'm currently doing. I actually just need a log file containing the style the Tomcat logs use, probably capturing System.out and System.err calls. I currently prefer configuring the Sun JDK logging, but that's not necessarily final.

I once used Commons Logging which I want to dump because of its classloading problems. IIRC Commons Logging was easy to configure, at least I can remember stdout_-date-.log and stderr_-date-.log files in tomcat/logs. I already use embedded JBoss, Hibernate and Seam so there's already a log4j.xml in tomcat/lib, but I doubt I really need the more complicated logging system, so I was looking if I can get these log files to go without Commons Logging.

The question is: Is the JDK 1.4 logger any simpler to configure than log4j or logback? Am I mistaken? After all, I can't find any simple examples other than already slightly complicated http://www.javapractices.com/topic/TopicAction.do?Id=143. Then I can go for log4j or logback right away, what do you think?

Karsten


OCJP JavaSE 6 (86%)
Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

For anybody interested in Windows localhost setups without installer using Tomcat as Windows service:

if you are wondering why your System.out and System.err prints aren't captured and/or Hibernate doesn't print to any logs even though you have set you must have set a correct logging path under the Logging tab (start tomcatw.exe as ADMIN!). Setting the path plus stdout and stderr to auto will create the stdout_ and stderr_ log files (server restart) that you and Hibernate will write to...

It doesn't however answer my original question.

Karsten
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

slf4j isn't a logger. It's a logging integrator that allows complex apps that use multiple logging facilities to get them all merged down into one consistent logging subsystem. Hibernate uses it.

I often use the JRE builtin logger, sometimes known as "juli" (for java utilities logging interface). However, its main drawback is that by default it looks in the JVM for the log configfile. Log4j uses a config file that's located in the app classpath, and that generally works better for webapps (for me, anyway). Then again, juli is built-in. No need to add a separate logging class jarfile.

I don't consider either of them especially hard to install or configure. My own preference is to use the xml config file format for Log4j. In fact, I think I have to to use the rolling logfile appenders.


Customer surveys are for companies who didn't pay proper attention to begin with.
Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

I know SLF4J just integrates. I agree that JULI's main drawback is the place where it looks for the config file. I'll finally give LOG4J a shot.

Thanks
Karsten
 
jQuery in Action, 2nd edition
 
subject: Simple logging config?