Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

java log4j custom appender and pattern

  • 25-04-2005 05:51PM
    #1
    Registered Users, Registered Users 2 Posts: 4,228 ✭✭✭


    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, Registered Users 2 Posts: 4,228 ✭✭✭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