[logback-user] How to log FROM an appender?
scohen at javactivity.org
Tue Nov 15 14:39:18 CET 2011
It's a JMSQueue-based appender. It was written for log4j (only recently
have we switched to logback) which didn't have one. In addition to the
JMS functionality, at the other end of the JMS socket sits a server
application written in C with its own legacy logging system that must be
catered to. This involves some special formatting and data which is
neither necessary nor desirable for inclusion in the local logging that
the client-side application also needs. The appender is perhaps the
most convenient place to do this.
However, I do suppose that I should look at the layout and custom format
specifier supported by logback as a possibly better way to accomplish
the same thing. But what I have seems to work.
On 11/14/2011 09:37 PM, TJ Rothwell wrote:
> I'm curious: what use-case is fulfilled by the additional messages
> generated by the appender?
> -- TJ
> On Mon, Nov 14, 2011 at 4:00 PM, Steve Cohen<scohen at javactivity.org> wrote:
>> On 11/12/2011 04:14 PM, Steve Cohen wrote:
>>> We have a custom appender that may itself need to issue logging
>>> statements. But placing a logger in such a class causes various
>>> exceptions on initialization and loading. So we are resorting to
>>> System.out.println for lack of a better solution.
>>> I suppose there must be a better way.
>>> What would that be?
>>> Logback-user mailing list
>>> Logback-user at qos.ch
>>> A technique that seems to work is to NOT declare a logger in the
>> Appender class that you want to use one from, but instead create a static
>> logger instance somewhere that is accessible through static methods. That
>> way the logger does not need to be created at the time of appender
>> Logback-user mailing list
>> Logback-user at qos.ch
> Logback-user mailing list
> Logback-user at qos.ch
More information about the Logback-user