Re: Log4j: Using servlet to init, but how to reload???

2002-10-23 Thread Kris Schneider
My current solution is to deploy the Log4j config file separately from the WAR 
file and use configureAndWatch. The idea is that the config file gets deployed 
to a directory that's included on the app server's classpath. The app can then 
locate the file through ClassLoader.getResource and URL.getFile.

That being said, what I'd rather do is find some time to investigate the JMX 
support and use that instead. Perhaps someone can offer a how-to along that 
line.

Quoting "Carson, Chuck" <[EMAIL PROTECTED]>:

> 
> I am using a servlet to intialize log4j as so:
> 
> public class Log4jInit extends HttpServlet
> {
> public void init()
> {
>   String prefix_dir   = getServletContext().getRealPath("/");
>   String param_file   = getInitParameter("log4j-init-file");
>   PropertyConfigurator.configure(prefix_dir + param_file);
> }
> 
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> {
> }
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> {
> }
> }
> 
> I have this in ROOT/WEB-INF/web.xml:
> 
> Log4jInit
> Log4jInit
> 
> log4j-init-file
> WEB-INF/log4j.config
> 
> 1
> 
> 
> This works fine, however, any changes made to log4j.config do not take effect
> until the server is restarted. Is the something I can code or something I can
> configure to change this?
> 
> Much thanks,
> Chuck
> 
> 
> --
> To unsubscribe, e-mail:  
> 
> For additional commands, e-mail:
> 
> 
> 


-- 
Kris Schneider 
D.O.Tech   

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Log4j: Using servlet to init, but how to reload???

2002-10-23 Thread Daniel Serodio
Have you tried using PropertyConfigurator.configureAndWatch(String
configFilename, long delay) instead of configure(String filename)?

On Wed, 2002-10-23 at 18:00, Carson, Chuck wrote:
> 
> I am using a servlet to intialize log4j as so:
> 
> public class Log4jInit extends HttpServlet
> {
> public void init()
> {
>   String prefix_dir   = getServletContext().getRealPath("/");
>   String param_file   = getInitParameter("log4j-init-file");
>   PropertyConfigurator.configure(prefix_dir + param_file);
> }
> 
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> {
> }
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> {
> }
> }
> 
> I have this in ROOT/WEB-INF/web.xml:
> 
> Log4jInit
> Log4jInit
> 
> log4j-init-file
> WEB-INF/log4j.config
> 
> 1
> 
> 
> This works fine, however, any changes made to log4j.config do not take effect until 
>the server is restarted. Is the something I can code or something I can configure to 
>change this?
> 
> Much thanks,
> Chuck
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
-- 
[]'s
Daniel Serodio


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Log4j: Using servlet to init, but how to reload???

2002-10-24 Thread Shapira, Yoav
Hi,

>
>Log4jInit
>Log4jInit
>
>log4j-init-file
>WEB-INF/log4j.config
>
>1
>

Just keep in mind that the server is not required to keep
load-on-startup servlets in memory.  It may destroy and deallocate them
at anytime, so the destroy() method of your init servlet is NOT a safe
place to do things like LogManager.shutdown().

A ServletContextListener would be a better choice for the above code.

>This works fine, however, any changes made to log4j.config do not take
>effect until the server is restarted. Is the something I can code or
>something I can configure to change this?

Did you try PropertyConfigurator.configureAndWatch()?  Then when you
change the file, log4j will pick it up automatically.

In addition, it is easy to write a page that will accept a logger name
and a logging level and set that logger to that level at runtime.  If
you think this approach would be useful for you and need more
information, let us know.

Yoav Shapira
Millennium ChemInformatics

This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: