LogMX and the Log4J SocketAppender
Moderator: admin
-
- Posts: 6
- Joined: Mon Mar 31, 2008 12:41 pm
LogMX and the Log4J SocketAppender
Does LogMX work with the org.apache.log4j.net.SocketAppender like chainsaw? and if so how do you configure it?
Hello,
At the moment, LogMX doesn't handle Log4j SocketAppender, but you can write your own Log Manager that handles it. But since it's a common way to monitor remote logs, LogMX will surely be delivered with such a Manager in a next release.
To get more information on LogMX Managers, please see http://www.logmx.com/p_manager_dev.php
Please note that user-defined Managers can only be used with the Professional version.
At the moment, LogMX doesn't handle Log4j SocketAppender, but you can write your own Log Manager that handles it. But since it's a common way to monitor remote logs, LogMX will surely be delivered with such a Manager in a next release.
To get more information on LogMX Managers, please see http://www.logmx.com/p_manager_dev.php
Please note that user-defined Managers can only be used with the Professional version.
-
- Posts: 6
- Joined: Mon Mar 31, 2008 12:41 pm
ok thanks! we are currently evaluating logmx as a replacement for chainsaw, clearly we would require the socket reciever to completely remove any need for chainsaw; if I'm able to get write a socket reciever and get it working, and logmx meets all of our other requirements; then yes, we would be looking at purchasing a number of professional licences.
-
- Posts: 6
- Joined: Mon Mar 31, 2008 12:41 pm
I have created a test calss for a user-defined log4j socket manager which works ok:
Would you be able to integrate this into a manager an put it in the next release?
Code: Select all
public static void main(String args[])
{
try
{
ServerSocket serskt = new ServerSocket(4560);
Socket skt = serskt.accept();
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(skt.getInputStream()));
// takes a few seconds...
System.out.println("connected");
org.apache.log4j.spi.LoggingEvent event = (org.apache.log4j.spi.LoggingEvent)ois.readObject();
System.out.print(event.getLoggerName());
System.out.print(event.getRenderedMessage());
}
catch (Exception e)
{
e.printStackTrace();
}
}
Thank you for this code. Indeed, it seems to match SocketAppender specifications (http://logging.apache.org/log4j/1.2/api ... ender.html).
But as you may have seen (link on previous message), LogMX Managers and "Auto Refresh" feature work this way:
- Periodically, the LogMX core asks the Manager the current size and timestamp for the input resource.
- If one of these values have changed since last time, LogMX core asks the Manager to read all bytes, starting from the last read byte
- LogMX makes the Parser process these new bytes (characters)
To use this SocketAppender code, the new LogMX Manager must support 'AutoRefresh' this way:
- put the bytes read from the socket in a local buffer, and wait for LogMX core to ask the current timestamp/size (this Manager may update these 2 values when new bytes are read from the Socket)
- send characters to LogMX and not instances of LoggingEvent (raw bytes read from socket can be sent to a new Log4JSocketAppenderParser, or this LoggingEvent object can be re-serialized in a more common file format)
LogMX v1.2.2 free version comes with an example of user-defined Manager: see "managers/" LogMX directory.
This directory also contains an Eclipse project and a Ant file so that you can compile this Manager.
To help you in writing this class, you can use the LogMX API Javadoc in LogMX "help/api/" directory.
But as you may have seen (link on previous message), LogMX Managers and "Auto Refresh" feature work this way:
- Periodically, the LogMX core asks the Manager the current size and timestamp for the input resource.
- If one of these values have changed since last time, LogMX core asks the Manager to read all bytes, starting from the last read byte
- LogMX makes the Parser process these new bytes (characters)
To use this SocketAppender code, the new LogMX Manager must support 'AutoRefresh' this way:
- put the bytes read from the socket in a local buffer, and wait for LogMX core to ask the current timestamp/size (this Manager may update these 2 values when new bytes are read from the Socket)
- send characters to LogMX and not instances of LoggingEvent (raw bytes read from socket can be sent to a new Log4JSocketAppenderParser, or this LoggingEvent object can be re-serialized in a more common file format)
LogMX v1.2.2 free version comes with an example of user-defined Manager: see "managers/" LogMX directory.
This directory also contains an Eclipse project and a Ant file so that you can compile this Manager.
To help you in writing this class, you can use the LogMX API Javadoc in LogMX "help/api/" directory.