logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hendry Taylor <aciddra...@gmail.com>
Subject Re: adding lower level debug statements for context-information
Date Wed, 25 Aug 2010 13:29:23 GMT
What is your logger level set to in the appender config?
that is what determines what level is logged.



On 25 August 2010 14:08, Carlos Freund <karlsfriend@yahoo.de> wrote:

> Hello,
>
> I've been using log4j for some time now and it's working really fine.
> However i have trouble with setting the log-levels right.
>
> I am working on a server that gets quite some load.
> At first I set the log-level to debug. This was very convenient for, well,
> debugging. When the server got heavier load this got impractical because the
> log files would inflate and IO caused by logging became noticeable.
>
> So i set the log level to warn. That solved those problems. But now when
> the occasional error occurs it has become much harder to figure out why.
> Before I had the debug statements from which I could tell, what was wrong.
> Now i just have a Exception and a stacktrace, which sometimes just isn't
> enough information.
>
>
> So what I'd really like would be a compromise of these two options. I was
> thinking about a possibility to configure a logger so it would add the last
> X log
> messages of lower levels whenever an log of the "regular" level would be
> written.
>
> A Simple example:
>
> public double getAvgAge(List<Person> persons){
>  LOG.debug("Calulating average age for persons: "+persons);
>  try{
>    int total_age = getTotalAge(persons);
>    double avg_age = total_age / persons.size();
>    return avg_age;
>  } catch (Exception e ){
>    LOG.error("Could not calculate average age");
>    throw e;
>  }
> }
>
>
>  I'd like to be able to set up log4j so that it doesn't log anyting if the
> code works(calls no LOG.error). But when it does call LOG.error i'd like to
> also see the previous debug statements in my log so I can figure out why my
> code failed.
>
> So i would read something like this in my log:
> DEBUG AverageAgeCalculator: Calulating average age for persons: [ ]
> ERROR AverageAgeCalculator: DivideByZeroError
> ....stacktrace....
>
> But no unnecessary statements like:
> DEBUG AverageAgeCalculator: Calulating average age for persons: [Mary,
> Peter ]
> DEBUG AverageAgeCalculator: Calulating average age for persons: [Carlos,
> Hans, Klaus]
>
>
> I happen to have some free time on my hands so i'd like to try to code this
> myself.
> But before i start thinking about implementation, I would like to know some
> things.
>
> Does something like this already exist?
> Do you think this would be useful?
>
> Greetings, Carlos Freund
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message