The log4j API does not provide a way to "set" a marker that will be emitted on 
all events produced by that logger. 

However, one idea is to generate a logger wrapper and write the above logic in 
the wrapper. Log4j provides a tool to generate logger wrappers for custom log 
levels. This will give a good starting point. 

Let me know if you have questions. 
Remko

Sent from my iPhone

> On 2016/03/29, at 10:58, Maple Wang <[email protected]> wrote:
> 
> Hi Gary,
> 
> Yes, I want to use specific marker on one more loggers, I mean current way of 
> using marker is not so convenient if I want to add same marker to multiple 
> log records, so I require to add marker to a logger directly, then all log 
> records using this logger will have this marker automatically, do we have 
> this feature now in log4j2.5? or is there any workaround to achieve this?
> 
> Best regards.
> 
> -----Original Message-----
> From: Gary Gregory [mailto:[email protected]] 
> Sent: Monday, March 28, 2016 10:41 PM
> To: Log4J Users List
> Subject: Re: is there any way to add a marker to a logger rather than a log
> 
> Do you plan on using this marker with more than one logger?
> 
> Gary
>> On Mar 28, 2016 1:35 AM, "Maple Wang" <[email protected]> wrote:
>> 
>> Hi,
>> 
>> 
>> 
>> Marker is great feature for classifying and filtering log content, but 
>> I have a question about how to use marker in logging API. In official 
>> guide for log4j2.x, normally, we need to do as blow:
>> 
>> 
>> 
>> Marker myMarker =  MarkerManager.getMarker("myMarker");
>> 
>> LOGGER.info(myMarker,"some log message");
>> 
>> 
>> 
>> This is good, but in my situation, I want to add a marker directly to 
>> a LOGGER, then, every time user use "LOGGER.info("some log 
>> message");", the marker will be added automatically. Is there any way 
>> to help me to achieve this?
>> 
>> 
>> 
>> Thanks in advance.
>> 
>> 
>> 
>> Best regards.
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to