You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Rebecca Ahlvarsson <ra...@gmail.com> on 2014/08/04 16:08:48 UTC

How to log to a regular file without using levels (warn, info, etc) ?

I am interested in using log4j for audit logging, in other words, I will
open my own file and start logging anything I want. Therefore I do NOT want
to use warn, info or any log level. Something like that:

Log log = new Log("blah.txt");
log.log("Test");
log.close();

How can I do that with LOG4J?

A concrete example that I can run will be very appreciated.

Thanks,

Rebecca Ahlvarsson

Re: How to log to a regular file without using levels (warn, info, etc) ?

Posted by Ralph Goers <ra...@dslextreme.com>.
Yes.  Use a Marker on your Audit events and then add a global filter that accepts events with those Markers.

Ralph

On Aug 4, 2014, at 8:00 AM, Matt Sicker <bo...@gmail.com> wrote:

> Take a look at the EventLogger:
> 
> http://logging.apache.org/log4j/2.x/manual/eventlogging.html
> 
> Javadocs:
> http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/EventLogger.html
> http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/message/StructuredDataMessage.html
> http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/ThreadContext.html
> 
> 
> On 4 August 2014 09:08, Rebecca Ahlvarsson <ra...@gmail.com> wrote:
> I am interested in using log4j for audit logging, in other words, I will open my own file and start logging anything I want. Therefore I do NOT want to use warn, info or any log level. Something like that:
> 
> Log log = new Log("blah.txt");
> log.log("Test");
> log.close();
> 
> How can I do that with LOG4J?
> 
> A concrete example that I can run will be very appreciated.
> 
> Thanks,
> 
> Rebecca Ahlvarsson
> 
> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>


Re: How to log to a regular file without using levels (warn, info, etc) ?

Posted by Matt Sicker <bo...@gmail.com>.
Take a look at the EventLogger:

http://logging.apache.org/log4j/2.x/manual/eventlogging.html

Javadocs:
http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/EventLogger.html
http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/message/StructuredDataMessage.html
http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/ThreadContext.html


On 4 August 2014 09:08, Rebecca Ahlvarsson <ra...@gmail.com> wrote:

> I am interested in using log4j for audit logging, in other words, I will
> open my own file and start logging anything I want. Therefore I do NOT want
> to use warn, info or any log level. Something like that:
>
> Log log = new Log("blah.txt");
> log.log("Test");
> log.close();
>
> How can I do that with LOG4J?
>
> A concrete example that I can run will be very appreciated.
>
> Thanks,
>
> Rebecca Ahlvarsson
>
>


-- 
Matt Sicker <bo...@gmail.com>