In theory, what you are describing should be working. Are the two classes in
one jar with Log4j in separate jars? Is it possible for you to provide a zip of
your project with the two classes exactly as it is packaged?
Ralph
On Oct 22, 2012, at 5:51 PM, Peter DePasquale wrote:
> Ok, I'm new, and I'm stumped. Here's my log4j2 config file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="debug">
> <appenders>
> <Console name="Console" target="SYSTEM_OUT">
> <PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level
> %logger{36} - %msg%n"/>
> </Console>
>
> <File name="DriversFile" fileName="trace-drivers.txt"
> suppressExceptions="false" append="false">
> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %C
> [%t] %m%n"/>
> </File>
> </appenders>
>
> <loggers>
> <logger name="org.comtor.drivers" level="trace"
> additivity="false">
> <appender-ref ref="DriversFile"/>
> </logger>
>
> <root level="error">
> <appender-ref ref="Console"/>
> </root>
> </loggers>
> </configuration>
>
> Note that the config status="debug". I have two classes that I'm
> monkeying with to get Log4J2 working. They are:
>
> org.comtor.drivers.Comtor, and
> org.comtor.drivers.ComtorStandAlone
>
> At this point, I'm only using a handful (and I mean small numbers
> here) of .trace(), .entry(), and .exit() method calls.
>
> If I do this in file #2 (ComtorStandAlone), I can get the tracing to
> write to the file specified in the config file above (as well as DEBUG
> statements from log4j2 on the console). Ok, cool. But when I add
> logging to the first file (Comtor) thereby in theory logging from two
> classes in the program, NOTHING happens. No config file logging to the
> console, no output file, nothing.
>
> Am I misunderstanding the capability to have the "org.comtor.drivers"
> logger catch, process, and write to the same file? In fact, if I only
> create the Logger object in the second file (private static Logger
> logger = LogManager.getLogger(Comtor.class.getName());) without
> attempting to call .trace(), .entry(), or .exit(), the problem
> manifests itself (no output, no file, nothing).
>
> I'd appreciate any insight here, as I'm really at a loss. Thanks.
>
> --
> Peter J. DePasquale, Ph.D.
> Department of Computer Science
> The College of New Jersey
> (e) depasqua [at] tcnj [dot] edu
> (p) 609-771-2806
> (f) 609-637-5190
> (o) Holman Hall - Room 238
> (l) Holman Hall - Room 255
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]