This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

A Log4j Stumper, can't get logs in the right place.

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I want to log a process into a special log file. I setup a special category for it and I initalize it correctly. But I don't want the log statments to print in the stdout console log.
How do I do that? Here's my current log4j properties file:
#### Setup the Categories
# This is where we setup our debug levels.
# All appenders must be in this list to be initialized correctly.
# You MUST have the ', appender' for this to work!
####
log4j.rootLogger=warn,stdout
# Debug logging per class
log4j.logger.irwin.comm=debug,soap
log4j.logger.floodix=debug,soap
#### Setup the Appenders
# To add an appender, simply copy the soap section. Change all places you see 'soap' to whatever
# you want the appender to be named. Change the end of the 'File' line to the appropriate log location/name.
####
# stdout log - Use this appender if you want to use log4j to log to the console.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{dd MMM yyyy HH:mm:ss,SSS}] %-5p %c{1} %x - %m%n
# soap log
log4j.appender.soap=org.apache.log4j.RollingFileAppender
log4j.appender.soap.File=/logs/flood_ix.log
log4j.appender.soap.Append=true
log4j.appender.soap.MaxFileSize=1500KB
log4j.appender.soap.MaxBackupIndex=5
log4j.appender.soap.layout=org.apache.log4j.PatternLayout
log4j.appender.soap.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss.SSS} %p - %m%n
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

log4j.rootLogger=warn,stdout


Change the log4j property to
log4j.rootLogger=warn
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
logger.setAdditivity(false);
is also a possibility, to avoid logging to a logger up the hieracy
 
Margit Bork
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does i work for you to set the log4j.rootLogger to warn ?
When i try to get a logger that does not make output unles the logger is specified i fail. I mean if i havent specified the logger that i instantiate it get at default loglevel on debug - and i dont want that.
I hope it is possible to define a hieracy of loggers mirroring my class hieracy, so that i dont have to make a specific configuration for each class's logger (I want each class to have its own logger to be able to pinpoint logging in the production environment )
Any experience with this ??
 
Nothing up my sleeve ... and ... presto! A tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!