Using HTMLLayout

2007-01-18 Thread chuanjiang lo

Hi,

I am using HTMLLayout and logging into an html file.
Whenever the server restarts, it will continue logging into the same
previous html file.

I notice that the whole html header is appended into the html file again
because of the getHeader() in HTMLLayout class.
Is there anyway to avoid this? If the html file already exist, do not call
getHeader() method?

Regards


Re: Loading sequence of log4j

2006-12-27 Thread chuanjiang lo

On 12/27/06, chuanjiang lo <[EMAIL PROTECTED]> wrote:


I am using PropertyConfigurator.configure in the Listener class

 PropertyConfigurator.configure(event.getServletContext
().getRealPath("")+"/WEB-INF/foo.xml");

Log4j is picking up foo.xml, However it seems like the logging events does
not behave as what foo.xml specifies. Nothing has changed.
Appreciate any kind advice.




Learnt the mistake here.
I should be using DOMConfigurator.configure()

One thing i notice for PropertiesConfigurator

for e.g.
Properties props = new Properties();
props.put("admin-console-abs-home", path);
in = this.getClass().getClassLoader().getResourceAsStream("foo.properties
");
props.load(in);
PropertyConfigurator.configure(props);

In this case in foo.properties, we are able to use ${admin-console-abs-home}
as a variable.
Is there any method for DOMConfigurator?


Re: Loading sequence of log4j

2006-12-26 Thread chuanjiang lo

On 12/27/06, chuanjiang lo <[EMAIL PROTECTED]> wrote:




Appreciate your advice.

How do i manually configure the log4j config file to point to WEB-INF?




I am using PropertyConfigurator.configure in the Listener class

PropertyConfigurator.configure(event.getServletContext
().getRealPath("")+"/WEB-INF/foo.xml");

Log4j is picking up foo.xml, However it seems like the logging events does
not behave as what foo.xml specifies. Nothing has changed.
Appreciate any kind advice.


Re: Loading sequence of log4j

2006-12-26 Thread chuanjiang lo

On 12/27/06, Jacob Kjome <[EMAIL PROTECTED]> wrote:



3.  Implement a servlet context listener  and implement the
contextInitialized() method (off the top of my head, I think that's
what it is called).  Set you system property first and then manually
configure log4j, pointing it to your real config file somewhere under
WEB-INF.



Appreciate your advice.

How do i manually configure the log4j config file to point to WEB-INF?


Loading sequence of log4j

2006-12-26 Thread chuanjiang lo

Hi all

I have this start up servlet that does the initializing some system
parameters.

1
And i place this servlet on the first priority

In the servlet i have something..
System.setProperty("admin-console-abs-home",
getServletContext().getRealPath("")+getServletConfig().getInitParameter("adminConsoleLog"));

So the log4j.xml uses something like


Sometimes the Start up servlet runs first and initalize the property. But at
times log4j starts first and giving an error
log4j:ERROR setFile(null,true) call failed.

So how can i ensure that log4j initalizes only after my start up servlet
finishes initalizing?


Changing appenders during runtime

2006-12-06 Thread chuanjiang lo

Hi all,

Suppose i have 2 appenders namely A1 and A2 and only A1 is attached to a
logger and this is configure in a XML file.

Is it possible to switch from A1 to A2 appender during runtime?


Re: Setting up log4j.xml

2006-12-05 Thread chuanjiang lo

On 12/6/06, Jacob Kjome <[EMAIL PROTECTED]> wrote:



Bender,

You are correct in your latest analysis, but incorrect on your original
analysis.  Chuanjiang's original XML file was just fine and the fact that
he
increased the level to "error" should have made it so that only ERROR
messages
would print to the A1 appender for that specific logger, while all other
loggers would print to the "debug" level.

There are a couple possibilities why this might not be working.

1.  As you mentioned, the logger name might not exactly match that being
referenced in the log4j.xml file

2.  Another config file is being used instead of this one.


Note that the approach I would generally take to configuration is to set
the
root logger to some higher level such as "warn" and then selectively set
loggers to debug where I truly want to see debug output.


Jake




Appreciate all help,

Indeed the logger name is does not match the one being referenced in the
log4j.xml file.

instead of
Logger mylogger = Logger.getLogger("Main" );

should be
Logger mylogger = Logger.getLogger("loggingexample.Main" );

Should have check throughly.
Thanks guys


Re: Setting up log4j.xml

2006-12-05 Thread chuanjiang lo

On 12/5/06, Bender Heri <[EMAIL PROTECTED]> wrote:


Log events which are sent to a specialized Logger (=not Root Logger) will
by default climb up the logger hierarchy until the root logger and serve
every appender of every logger found on its way. Your example: a log event
sent to logger named "loggingexample.Main" arrieves to this logger, does
not find an appender, looks up the next upper logger in hierarchy, finds the
root logger with level DEBUG and serves its appender A1.

To achieve what you want, supply the logger "loggingexample.Main" with the
appender-ref A1 and set the logger's property additivity=false. This will
prevent the log event to climb further up the hierarchy.


 
 
 

Heri



This is my current xml configuration..somehow the class Main still prints
out those levels that are below error.

http://jakarta.apache.org/log4j/";
debug="false">

   
   
   
   

   
   

   
   
   
   

   
   
   
   



Re: Setting up log4j.xml

2006-12-04 Thread chuanjiang lo

i'm having this config..
i would like to print out error and fatal msgs in the Main class of
loggingexample package, how come it is still printing debug level and above
msgs?

appreciate any help

   
   
   
   

   
   

  
   
   

   
   
   
   


Re: Setting up log4j.xml

2006-12-03 Thread chuanjiang lo

On 12/3/06, James Stauffer <[EMAIL PROTECTED]> wrote:


Set a threshold on info appender and send root logs to both appenders.




i found this great example on the net

http://wiki.apache.org/logging-log4j/LogByLevel

appreciate your help!


Setting up log4j.xml

2006-12-01 Thread chuanjiang lo

Hi all,

I would like to know how i can set up my log4j.xml, for e.g info level would
be printed onto the console where debug level would be log into a file.

These are the snippets of my log4j.xml


   
   
   
   

   
   
   
   

   
   
   
   

I'm not very sure how i can set up the environment, probably need some
advice from experienced users.

Appreciate any help


Using XML configurations

2006-07-06 Thread chuanjiang lo

Hi all,

There is no problem using the properties file now I'm using a XML file for
configuring the properties.




http://jakarta.apache.org/log4j/";>

   
   
   
   


   
   
  
 
   




However it is giving me error when im running my program.

Error output:

javax.xml.parsers.FactoryConfigurationError: Provider org
jaxp.DocumentBuilderFactoryImpl not found

and more

Using JDK 1.5

Appreciate any help.