← All posts

WLST Script to enabe Log4j Logger on a weblogic server

Switch from Java Logging to Log4j via WLST

Unni Pillai
Unni Pillai

WebLogic logging services use an implementation based on the Java Logging APIs, by default. Using the LogMBean.isLog4jLoggingEnabled attribute, you can direct the logging services to use Log4j instead.

Posted by Unni# Start WLST

  1. C:\>java weblogic.WLST

  2. # connect Administration Server

  3. wls:/offline> connect(‘uname’,‘password’)

  4. # Start an edit session and navigating to the logging mbean for the server names myserver

  5. wls:/mydomain/serverConfig> edit()

  6. wls:/mydomain/edit> startEdit()

  7. wls:/mydomain/edit !> cd(“Servers/myserver/Log/myserver”)

  8. # enable log4j

  9. wls:/mydomain/edit/Servers/myserver/Log/myserver !> cmo.setLog4jLoggingEnabled(true)

  10. #save and activate the changes

  11. wls:/mydomain/edit/Servers/myserver/Log/myserver !> save()

  12. wls:/mydomain/edit/Servers/myserver/Log/myserver !> activate()

Java Logging is the default for client and server-side logging; Log4j is available only for server-side and not client-side logging.