Actually Matt, I don’t believe the routing appender will help for what he is 
asking for. Sorry to be blunt but it really makes no sense.

Log events get generated by an application and are routed to the appropriate 
LoggerConfig by way of a Logger. The LoggerConfig then routes them to the 
appropriate Appender(s).  The main difference between a “normal” LoggerConfig 
and an AsyncLoggerConfig is, of course, that one is synchronous and one is 
asynchronous. The main benefit of the asyncronous LoggerConfig is that when its 
queue isn’t full it will return back to the application almost immediately. 
Other than that they pretty much function the same. So if you were to have an 
event somehow routed to both a synchronous and asynchronous LoggerConfig you 
would now be waiting for the synchronous event to complete logging AND for the 
asynchronous event to be placed in the queue. That makes no sense as you are 
making your application perform slightly worse than in the synchronous case by 
itself.

If you perceive some other benefit to using both an asynchronous and a 
synchronous LoggerConfig please share that.

If, by chance you simply want the SyslogAppender to behave asynchronously then 
wrap it in an AsyncAppender. 

Ralph

> On Apr 16, 2021, at 6:32 AM, Matt Sicker <boa...@gmail.com> wrote:
> 
> You should take a look at the routing appender for supporting what you want
> to do. You can certainly keep the same logger name. You’d simply route log
> events based on other metadata. See:
> http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
> 
> On Fri, Apr 16, 2021 at 06:35 Lars-Fredrik Smedberg <itsme...@gmail.com>
> wrote:
> 
>> Hi
>> 
>> We have different appenders, one file appender and one syslog appender
>> amongst others. We want the file appender to use a normal Logger and the
>> syslog appender using an AsyncLogger. When the different
>> applications/functions perform the logging they don't know if it will end
>> up in the file appender only or in both the file appender and syslog
>> appender. The syslog appender have a filter (AlertFilter) that decides if
>> the log event will be accepted or not. The file appender has no filter.
>> 
>> The configuration looks like below (important parts included, some
>> attributes masked):
>> 
>> Any suggestion on how to be able to use the same logger name (which
>> obviously is not allowed) or achieve something that works the same way?
>> 
>> Best regards, preciate any help
>> LF
>> 
>> <Configuration status="debug" packages="xyz">
>>  <Appenders>
>>    <Console name="ConsoleLogAppender" target="SYSTEM_OUT">
>>      <PatternLayout pattern="%m"/>
>>    </Console>
>>    <Syslog name="AlertLogAppender" host="xyz" port="xyz" protocol="TCP"
>> format="RFC5424" facility="LOCAL6"
>>        includeMDC="false" enterpriseNumber="xyz" appName="xyz"
>> newLine="true" messageId="Alert" id="App">
>>      <AlertFilter onMatch="ACCEPT" onMismatch="DENY"/>
>>    </Syslog>
>>    <RollingFile name="RollingFileAppender" fileName="logs/application.log"
>>        filePattern="logs/application.log.%i.gz" immediateFlush="true"  >
>>      <PatternLayout pattern =%m%n"/>
>>      <Policies>
>>        <OnStartupTriggeringPolicy/>
>>        <SizeBasedTriggeringPolicy size="10 MB"/>
>>      </Policies>
>>      <DefaultRolloverStrategy max="2"/>
>>    </RollingFile>
>>  </Appenders>
>>  <Loggers>
>>    <AsyncLogger name="foo" level="info" additivity="false">
>>      <AppenderRef ref="AlertLogAppender"/>
>>    </AsyncLogger>
>>    <Logger name="foo" level="info" additivity="false">
>>      <AppenderRef ref="RollingFileAppender"/>
>>    </Logger>
>>    <Root level="warn">
>>      <AppenderRef ref="ConsoleLogAppender"/>
>>    </Root>
>>  </Loggers>
>> </Configuration>
>> 
>> --
>> Med vänlig hälsning / Best regards
>> 
>> Lars-Fredrik Smedberg
>> 
>> STATEMENT OF CONFIDENTIALITY:
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of the
>> address(es) and may contain confidential or privileged information. If
>> you are not the intended recipient, please notify Lars-Fredrik Smedberg
>> immediately at itsme...@gmail.com, and destroy all copies of this
>> message and any attachments.
>> 



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

Reply via email to