You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Brett Delle Grazie <br...@gmail.com> on 2014/08/19 13:25:55 UTC

Log4j2 SyslogAppender / SyslogLayout and message format

Hi,

I'm trying to use the SyslogAppender and possibly the SyslogLayout but I
wanted to customise the message format so that some MDC parameters could be
added to the content of the message (e.g. by applying a pattern layout to
the 'message' portion).

Is there any way of achieving this? There used to be with Log4j 1.2.

I appreciate that this can be done with format 5424 but we're using BSD
format right now.

Thanks,

-- 
Kind regards,

Brett

Re: Log4j2 SyslogAppender / SyslogLayout and message format

Posted by Ralph Goers <ra...@dslextreme.com>.
I thought about this when I implemented the SyslogLayout. The problem here is that only a subset of the pattern converters should be available in the SyslogLayout since some of them are already there.  What you are proposing below changes the semantics of a Layout - they have access to everything in the log event and format the entire event, not just the message field. It could certainly be possible to do what you are suggesting but I have a concern that it could be confusing.

Ralph

On Aug 22, 2014, at 3:32 PM, Brett Delle Grazie <br...@gmail.com> wrote:

> Hi,
> 
> Specifically I'm trying to do something like:
> 
> <Syslog name="syslog" host="127.0.0.1" port="514" facility="local1"
> protocol="UDP">
>   <!-- Here the pattern layout is only supposed to be the text / message
> part of syslog record i.e. not the date/time stamp etc. -->
>  <PatternLayout pattern="%-40.40c %-25.25t %X %m" />
> </Syslog>
> 
> Thanks,
> 
> Brett
> 
> 
> 
> On 20 August 2014 20:30, Gary Gregory <ga...@gmail.com> wrote:
> 
>> Hello,
>> 
>> Can you give us a specific example of what you'd like to achieve?
>> 
>> Thank you,
>> Gary
>> 
>> 
>> On Tue, Aug 19, 2014 at 7:25 AM, Brett Delle Grazie <
>> brett.dellegrazie@gmail.com> wrote:
>> 
>>> Hi,
>>> 
>>> I'm trying to use the SyslogAppender and possibly the SyslogLayout but I
>>> wanted to customise the message format so that some MDC parameters could
>> be
>>> added to the content of the message (e.g. by applying a pattern layout to
>>> the 'message' portion).
>>> 
>>> Is there any way of achieving this? There used to be with Log4j 1.2.
>>> 
>>> I appreciate that this can be done with format 5424 but we're using BSD
>>> format right now.
>>> 
>>> Thanks,
>>> 
>>> --
>>> Kind regards,
>>> 
>>> Brett
>>> 
>> 
>> 
>> 
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>> 
> 
> 
> 
> -- 
> Kind regards,
> 
> Brett Delle Grazie


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Log4j2 SyslogAppender / SyslogLayout and message format

Posted by Brett Delle Grazie <br...@gmail.com>.
Hi,

Specifically I'm trying to do something like:

<Syslog name="syslog" host="127.0.0.1" port="514" facility="local1"
protocol="UDP">
   <!-- Here the pattern layout is only supposed to be the text / message
part of syslog record i.e. not the date/time stamp etc. -->
  <PatternLayout pattern="%-40.40c %-25.25t %X %m" />
</Syslog>

Thanks,

Brett



On 20 August 2014 20:30, Gary Gregory <ga...@gmail.com> wrote:

> Hello,
>
> Can you give us a specific example of what you'd like to achieve?
>
> Thank you,
> Gary
>
>
> On Tue, Aug 19, 2014 at 7:25 AM, Brett Delle Grazie <
> brett.dellegrazie@gmail.com> wrote:
>
> > Hi,
> >
> > I'm trying to use the SyslogAppender and possibly the SyslogLayout but I
> > wanted to customise the message format so that some MDC parameters could
> be
> > added to the content of the message (e.g. by applying a pattern layout to
> > the 'message' portion).
> >
> > Is there any way of achieving this? There used to be with Log4j 1.2.
> >
> > I appreciate that this can be done with format 5424 but we're using BSD
> > format right now.
> >
> > Thanks,
> >
> > --
> > Kind regards,
> >
> > Brett
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Kind regards,

Brett Delle Grazie

Re: Log4j2 SyslogAppender / SyslogLayout and message format

Posted by Gary Gregory <ga...@gmail.com>.
Hello,

Can you give us a specific example of what you'd like to achieve?

Thank you,
Gary


On Tue, Aug 19, 2014 at 7:25 AM, Brett Delle Grazie <
brett.dellegrazie@gmail.com> wrote:

> Hi,
>
> I'm trying to use the SyslogAppender and possibly the SyslogLayout but I
> wanted to customise the message format so that some MDC parameters could be
> added to the content of the message (e.g. by applying a pattern layout to
> the 'message' portion).
>
> Is there any way of achieving this? There used to be with Log4j 1.2.
>
> I appreciate that this can be done with format 5424 but we're using BSD
> format right now.
>
> Thanks,
>
> --
> Kind regards,
>
> Brett
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory