Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple logging config?

 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic