I think that Mark will find this fascinating. I sure do.


At 03:00 PM 12/8/2003 +0100, ROQUES Arnaud - NTR ( [EMAIL PROTECTED] ) wrote:
Hi!

log4j is great, but I think that
PropertyConfigurator.configureAndWatch(String configFilename) is not good
enough for
dynamic modification, as you have to wait until the delay so that your
modification are taken into account.

So I imagine a solution: to put a *very* little FTP server in the
application on a particular port (example:2100).
When you put a file on this server, the file is not saved on disk, but sent
to PropertyConfigurator, so that modifications of the configu are taken into
account immediatly. (You can log with any username and password)

(Some text editor have embedded FTP client, so it can be very easy to change
the log4j configuration with them)

I have coded this little FTP server, so if you want to use it, all you have
to do is:

PropertyConfigurator.configure("myconf.properties"); // As usually
new FTPServer(2100, "myconf.properties"); // Launch the server on the 2100


Note that when you put some files on the FTP server, data are *not* saved to
disk. It's only sent to log4j PropertyConfigurator. (You can also get the
last config from the FTP server).

Please free to improve it, or to integrate it in next version of log4j!

Arnaud Roques

FTPServer.java file:
------------------------

import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.log4j.*;

public class FTPServer extends Thread
{
        ServerSocket server;
        ArrayList data;

        FTPServer(int port, String fileName) throws Exception
        {
                data = new ArrayList();
                File f = new File(fileName);
                BufferedReader br = new BufferedReader(new FileReader(f));
                String s;
                while ((s=br.readLine())!=null)
                        data.add(s);
                server = new ServerSocket(port);
                System.err.println("FTP Server on " +
InetAddress.getLocalHost().getHostAddress()+" "+port);
                start();
        }

[cut] -- Ceki Gülcü

For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to