• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to configure log4j.properties correctly?

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I am trying to setup a logging on my application. What I generally want is that when I use logger.info() method, the log will be stored in info.log file and when I use logger.error() the message will be stored in error.log file. So far what happens is that when I use logger.info() it stores only in info.log file however if I use logger.error() method, the message stores both in info.log and error.log files.

Here's my config:

 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The logging system is working exactly as designed.
When you specify a level of logging, it assumes you want to know everything above that level as well.

At ERROR level you would only see ERROR
At WARN level you see ERROR and WARN
At your INFO level logging you will get all of ERROR, WARN and INFO
etc etc.

I don't know of any easy way to say "include only INFO messages, but nothing from a "higher" level.

I think your easiest path forward would be to accept this as a standard approach to logging, and adjust your expectations appropriately.

Quick example of the general approach of things:



The "ERROR" filter would only show you the catastrophic messages
INFO would see that plus some info on what the user was doing
DEBUG would let you see even more again.

 
Matt Taylor
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply. However, I defined my APPINFO to filter only INFO using the code:

log4j.appender.APPINFO.Threshold=INFO

Based on my understanding, if I set my Threshold to INFO, it should only filter INFO (not ERROR, WARN ETC BUT ONLY INFO LEVEL). Is this correct?
reply
    Bookmark Topic Watch Topic
  • New Topic