I am using log4j for logging messages. Currently I am using Socket Appender to send logs to server. This is working fine (client side). But, how to listen and read these logs at Server Side? Is there any log4j service to listen and read logs at server side? If Yes then share sample code with me.
Thanks in advance.
This is my log4j.xml file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info">
<Appenders>
<Socket name="client" host="localhost" port="5000" protocol="TCP" >
<PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | [%t] %C{2} (%F:%L) - %m%n"/>
<PatternLayout/>
</Socket>
</Appenders>
<Loggers>
<Logger name="Xyz" level="debug"/>
<AsyncLogger name="com.xyz" level="info" includeLocation="true">
<AppenderRef ref="client"/>
</AsyncLogger>
</Logger> -->
<!-- root loggers -->
<Root level="info" includeLocation="true">
<AppenderRef ref="client"/>
</Root>
</Loggers>
</Configuration>
This is my Client.java class
public class Client{
final static Logger logger = LogManager.getLogger(Client.class);
public static void main(String[] args) {
Client obj = new Client();
logger.error("Sorry, something wrong!");
}
}