Return-Path: X-Original-To: apmail-logging-log4j-user-archive@www.apache.org Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9E1719A1E for ; Tue, 29 Mar 2016 08:57:44 +0000 (UTC) Received: (qmail 49934 invoked by uid 500); 29 Mar 2016 08:57:44 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 49837 invoked by uid 500); 29 Mar 2016 08:57:44 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 49826 invoked by uid 99); 29 Mar 2016 08:57:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2016 08:57:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6E3ADC39DE for ; Tue, 29 Mar 2016 08:57:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.801 X-Spam-Level: X-Spam-Status: No, score=0.801 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RP_MATCHES_RCVD=-0.996, SPF_PASS=-0.001, TVD_PH_BODY_META=1.699] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id kciryNBfswUP for ; Tue, 29 Mar 2016 08:57:42 +0000 (UTC) Received: from BAY004-OMC3S25.hotmail.com (bay004-omc3s25.hotmail.com [65.54.190.163]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 68E395F234 for ; Tue, 29 Mar 2016 08:57:41 +0000 (UTC) Received: from BAY181-DS6 ([65.54.190.188]) by BAY004-OMC3S25.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 29 Mar 2016 01:57:34 -0700 X-TMN: [JajFQDx+DiPHNZQRQsPQcp6/71ea+jG3NfWda0jKQhc=] X-Originating-Email: [maple.feng.wang@hotmail.com] Message-ID: From: Maple Wang To: "'Log4J Users List'" References: <561DDEB0-4FCC-4F1C-9E5E-5580580AD187@gmail.com> In-Reply-To: <561DDEB0-4FCC-4F1C-9E5E-5580580AD187@gmail.com> Subject: RE: is there any way to add a marker to a logger rather than a log Date: Tue, 29 Mar 2016 16:57:32 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQM8Ut/UvTa7maw18zCVVRCScSLb+QKTxxQ6AgyQOoEA8QCdoJxuAB5A Content-Language: en-us X-OriginalArrivalTime: 29 Mar 2016 08:57:34.0257 (UTC) FILETIME=[08E34A10:01D18999] Hi Remko, Thanks for your suggestion, I extends the ExtendedLoggerWrapper and override logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) to add my specific marker, it works. But I still wonder if it's possible to enable user to add marker to logger through API directly, it could be a feature implemented in the feature. Best regards. -----Original Message----- From: Remko Popma [mailto:remko.popma@gmail.com] Sent: Tuesday, March 29, 2016 12:23 PM To: Log4J Users List Subject: Re: is there any way to add a marker to a logger rather than a log 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 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:garydgregory@gmail.com] > 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" 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: log4j-user-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-user-help@logging.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org