Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

java log4j custom appender and pattern

Options
  • 25-04-2005 5:51pm
    #1
    Registered Users Posts: 4,222 ✭✭✭


    Hi,
    i need to write a custom appender for log4j to write to a socket. I also need to write it in a specific string format so i guess i need to write a custom appender as well.
    Anyone got any examples or can point out good resources on the web.

    Cheers!


Comments

  • Closed Accounts Posts: 92 ✭✭tempest


    org.apache.log4j.net.SocketAppender (comes with log 4j, writes to socket).

    Then use a Layout to format the data to write to the socket.


  • Registered Users Posts: 4,222 ✭✭✭Scruff


    ok i've created my own custom appender and its working fine except if i try to configure it using a xml configuration file.

    if i try:
    <appender name="remoteAppender" class="com.test.logging.RemoteAppender">
    <param name="Host" value="localhost"/>
    <param name="Port" value="11013"/>
    </appender>

    i get the following error :
    log4j:WARN No such property [Host] in com.test.logging.RemoteAppender.
    log4j:WARN No such property [Port] in com.test.logging.RemoteAppender.

    why is it not setting the params propperly? how does log4j parse the xml config file and assign paramaters to the class?


  • Closed Accounts Posts: 92 ✭✭tempest


    Presumably you have a method called setPort(String port) and setHost(String host) methods on your class.

    If that's the case then I don't know because it looks right (as long as the casing is the same in the set methods i.e. Port != setport).


Advertisement