» tagged pages
» logout

(Feed found, click Add Page to syndicate.) Error finding feed, please try again » Find feed title

A Blog Page allows you to add entries, for news or other time sensitive postings

(Login required to save to your tagged pages.)
(or Cancel)

Make further edits, (or Cancel)

(Login required to save to your tagged pages.)
(or Cancel)

(Editing anonymously: to be credited for your changes, login or register a new account)

Change Page Permissions? Changing these permissions will adjust who can modify this page.

alex (change)
Swik Users (change)
(or Cancel)
Upload an image from your computer:
or Copy an image from a URL:
or Erase the current icon:
Icon Preview:

or Cancel

Erase log4j? The contents of log4j page and all pages directly attached to log4j will be erased.

or Cancel

(Editing anonymously: to be credited for your changes, login or register a new account)

other page actions:
log4j

log4j

Tags Applied to log4j

3 people have tagged this page:

Log4j is a logging package written in Java. This is now part of the Apache Logging Services.

SourceLabs includes the ability to capture, search, sort and correlate Log4J messages with millions of datapoints as part of its Self-Support Suite for Linux and Open Source Java

logging.apache.org

sorted by: recent | see : popular
Content Tagged log4j

Red5 log forwarding to centralized log server

In order to view the log generated by Red5 in some other location( on a different log server on network), You can use the log4j feature to forward your logs to a centralized log sever, where all your applications( multiple red5 servers) are throwing their logs.This way you can later view your organize log through some log interface.

Here i will explain, How you can configure your log settings in your red5 application in order to acheive that.Let say you have an application with name Test.Open the log4j.properties file under your application WEB-INF folder, Initially the contents will be -

# logging config, this should be auto reloaded by spring.

Now you can change it to -

#-----------------------------------------------------------------

#log4j.rootCategory=, A1
#log4j.appender.A1=org.apache.log4j.net.SocketAppender
#log4j.appender.A1.RemoteHost=XX.XX.XX.XX
#log4j.appender.A1.Port=8888
#log4j.appender.A1.Threshold=DEBUG
#log4j.appender.A1.locationInfo=true

#----------------------------------------------------------------------

The above lines describes that upon running the application, it will connect to this remote address on port 8888.

Now you can also put the server name in your log messages, so that at receiving end, you can differentiate the log messages coming from different red5 servers. To acheive that, we will add some line in our application source.

//------------------------------------------------------------------

public boolean appStart(IScope app){

String servername = null;
try{
servername = java.net.InetAddress.getLocalHost().getHostName();
}
catch(UnknownHostException un){
log.error("Unknown host exception found while getting host name of sever " + un);
}
catch(Exception e){
log.error("Exception while getting host name of sever " + e);
}
if(servername != null){
MDC.put("red5server",servername);
}

log.info("AppStart called for : " + app.getName());

if (!super.appStart(app)){
log.error("Unable to start the application");
return false;
}

return true;
}

//-------------------------------------------------------------


You can see from the above piece of code, that we have created a variable called "red5server" and we are putting the server name in that.This variable will be accessed by log4j server later.

Now, the sending part is complete, We have to implement the receiving end i.e. The log4j server, which will receive all these log messages.

In order to run log4j server, you need to create a properties file. I am showing here, a sample file called "socketserver.properties". The contents of the file will be-

#--------------------------------------------------------------------

log4j.rootLogger=, A1

#log4j.appender.A1=org.apache.log4j.ConsoleAppender
#log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
#log4j.appender.A1.layout.ConversionPattern= %X{red5server} %5p [%t] (%F:%L) - %m%n


log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File= remote-log.log

log4j.appender.A1.MaxFileSize=1024KB

log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern= %1.25X{red5server}- %p %t %c - %m%n

#------------------------------------------------------------------

Now you can see from above lines, I have referred to the same variable, i have created in source file.

"log4j.appender.A1.layout.ConversionPattern= %X{red5server} %5p [%t] (%F:%L) - %m%n"

This piece of code will add the red5 server name in the begining of every log message.

You can now start the log4j server in order to receive the logs from applications in this way-

java -cp log4j-1.2.14.jar org.apache.log4j.net.SimpleSocketServer 8888 socketserver.properties

Now your log4j server is up and running, Every application, which is referring to this log server will throw their log messages to this server, which you can later on view.

Happy logging!!

To create new Red5 application, follow my post here

red5: Technology makes life easier

Log4jXmlFormat - Logging-log4j Wiki

ender-ref ref="console" />

XML: del.icio.us/tag/xml

Page 1 | Next >>
Username:
Password:
(or Cancel)