Hi Gareth,

You will probably want to get the latest version of the source.  I just
checked in some changes last night that make the appserver package a little
easier to configure.  An example program which uses it looks like this:

=========== Begin test.java =================
import org.apache.log4j.examples.appserver.AppServerCategory;
import org.apache.log4j.examples.appserver.AppServerPropConfigurator;
import org.apache.log4j.Category;
import org.apache.log4j.Priority;

public class test
{
     public static void main(String[] args)
     {
//        AppServerPropConfigurator.configure("test.properties");
          Category cat = AppServerCategory.getInstance("some.cat");

          cat.l7dlog(Priority.DEBUG, "msg01", null);
          cat.debug("This is a debug statement.");
          cat.info("This is an info statement.");
          cat.warn("This is a warning statement.");
          cat.error("This is an error statement.");
          cat.fatal("This is a fatal statement.");
          cat.shutdown();
     }
}
===========  End test.java  ===========================

Note that the call to the configurator is commented out.  I placed it in
there to test it (and this is how one would use it).  But the static
initializer in AppServerCategory can also do the job.  My configuration
file looks like this:

=========== Begin test.properties ========================
log4j.appserver.factory=org.apache.log4j.examples.appserver.AppServerCategoryFactory
log4j.appserver.factory.server=TestServer
log4j.appserver.factory.component=TestComponent
log4j.appserver.factory.version=SomeVersion
log4j.appserver.factory.msgfile=app_messages

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.examples.appserver.AppServerPatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%h:%s:%b:%v] %m%n

log4j.appender.dispatch=org.apache.log4j.net.SocketAppender
log4j.appender.dispatch.remoteHost=case
log4j.appender.dispatch.port=32496
log4j.appender.dispatch.locationInfo=false

log4j.category.some=DEBUG,stdout
============ End test.properties =========================

And my message file looks like this:

============ Begin app_messages.properties ===============
msg01=This is message number one.
msg02=Second example of a message.
msg03=The parameter is {0}.
============ End app_messages.properties =================

I run the program like this:

java -Dlog4j.defaultInitOverride=true -Dlog4j.configuration=test.properties
test

And I get the following output:

============= Begin Output ======================================
E:\samples\appserv\test>java -Dlog4j.configuration=test.properties
-Dlog4j.defaultInitOverride=true test
[molly:TestServer:TestComponent:SomeVersion] This is message number one.
[molly:TestServer:TestComponent:SomeVersion] This is a debug statement.
[molly:TestServer:TestComponent:SomeVersion] This is an info statement.
[molly:TestServer:TestComponent:SomeVersion] This is a warning statement.
[molly:TestServer:TestComponent:SomeVersion] This is an error statement.
[molly:TestServer:TestComponent:SomeVersion] This is a fatal statement.

E:\samples\appserv\test>
============= End Output ==========================================

If it is not practical for you to download the latest source, let me know.
I can send you a "helper class" (an initialization routine) that will get
everything started under the old system.

- Paul

Paul Glezen
IT Specialist
Software Services
818 539 3321


"Gareth Powell" <[EMAIL PROTECTED]> on 06/01/2001 05:25:58 AM

Please respond to "LOG4J Developers Mailing List"
      <[EMAIL PROTECTED]>

To:   <[EMAIL PROTECTED]>
cc:
Subject:  Using org.apache.log4j.examples.appserver




Hello  all,

     Could someone please send me some code examples of how to make use of
the  org.apache.log4j.examples.appserver package.

    i.e. Establishing a category, factory etc

    Thanks in advance

Gareth Powell

------------------------------------------------------------------------
Gareth Powell BSc. (Hons)
Java Software Engineer
TriNet IMB Ltd
Orchard House
Castle Garth
Kendal
Cumbria
LA9 7AT
www.trinetimb.com
t : +44 (0) 1539 731000
f : +44 (0) 1539 729995





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

Reply via email to