2

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!");
        }

    }
P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
Shekhar Jadhav
  • 1,035
  • 9
  • 20
  • Hi I don't see how is this jpos related, are talking about jpos (http://www.jpos.org/) or javapos (http://www.javapos.org/)? If the lates I suggest you to tag the question properly so that it reaches the correct people – Andrés Alcarraz Dec 14 '17 at 11:07
  • Yes I am talking about jpos (jpos.org) because I used jpos in my project and I want to implement log4j logging in my project. – Shekhar Jadhav Dec 14 '17 at 11:14
  • Ok, then I suggest you to improve your question and put the code and config you tried on your (client side) and what you mean about read logs om the (server side). I really cannot pinpoint what you are trying to achieve from your question. – Andrés Alcarraz Dec 14 '17 at 11:18
  • I just want to know that How to listen logs at Server Side???Is there any log4j feature for listening logs at server side? – Shekhar Jadhav Dec 14 '17 at 11:20
  • Can you elaborate more on your set up? How do you pretend to listening logs at server side? I really can't figure out what you even mean with that. I just think you need to improve your question – Andrés Alcarraz Dec 14 '17 at 11:24
  • 1
    Possible duplicate of [log4j: How to use SocketAppender?](https://stackoverflow.com/questions/11759196/log4j-how-to-use-socketappender) – Andrés Alcarraz Dec 14 '17 at 11:44
  • does this answer(https://stackoverflow.com/a/11759549/3444205) your question? – Andrés Alcarraz Dec 14 '17 at 11:45
  • yes partially same,but I want to know more about it..this answer is partially correct...I want to know in detail with an example. – Shekhar Jadhav Dec 15 '17 at 04:30
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/161275/discussion-between-shekhar-jadhav-and-andres-alcarraz). – Shekhar Jadhav Dec 15 '17 at 09:15
  • I really would like to help you more, but I sadly, I helped all I can. If your problem were jpos related I could be of more help. But with log4j my knowledge is pretty much limited. I sincerely wish you the best of luck. – Andrés Alcarraz Dec 15 '17 at 10:05

0 Answers0