Merge pull request #10983 from hmdrzsharifi/BAEL-4843

Bael 4843-Writing Log Data to Syslog Using Log4j
This commit is contained in:
Greg 2021-07-15 10:42:25 -04:00 committed by GitHub
commit 5ba5c1eda8
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package com.baeldung.syslog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootSyslogApplication {
private static final Logger logger = LogManager.getLogger(SpringBootSyslogApplication.class);
public static void main(String[] args) {
SpringApplication.run(SpringBootSyslogApplication.class, args);
logger.debug("Debug log message");
logger.info("Info log message");
logger.error("Error log message");
logger.warn("Warn log message");
logger.fatal("Fatal log message");
logger.trace("Trace log message");
}
}

View File

@ -22,6 +22,10 @@
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
<Syslog name="Syslog" format="RFC5424" host="localhost" port="514"
protocol="UDP" appName="baeldung" facility="LOCAL0" />
</Appenders>
<Loggers>
@ -29,6 +33,7 @@
<Root level="info">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />
<AppenderRef ref="Syslog" />
</Root>
<!-- LOG "com.baeldung*" at TRACE level -->