Use log4j2 in webmethods

Hi,

I have implemented the custom logging in 10.11 designer using the esb.log4j.xml file. The logs are getting generated in the provider and consumer side… But when the logs are getting generated the log entries are happening like this.

Provider side:

Consumer side:

Please help me to understand why is this coming in the red highlighted box, how to avoid getting this?

Hello Maheswari,

Its coming from the pattern layout. can you remove the [%t] in the log4j2 file and see. %t means the thread which is invoking the service.

Hi Saran,

I have also tried the same. it was working.

Thanks.

HI Maheshwari,

Thanks .im facing the issue where custom loggings were written to same file even though im calling from different packages.

To elaborate the issue ,i have added two packages a/config/ log4j2.xml,b/config/ log4j2.xml in custom wrapper .conf and when i called from any one packages all the logs are going to b.log.

Do you have any idea about this

Hi Saran,

What is the file path location we have specified in the log4j2.xml file, the logs will be placed there.
image

Can you please provide different file path in these two log files and check the logs.
Thanks.

Hello Maheswari/All

Yeah i did that too .But its writing to same file. initially it created 2 files for each log4j2 config but its writing the logs to only one file.

any idea.

java code:

	public static final void loggingcheck(IData pipeline) throws ServiceException {
                loggername="namespace.pkg1"(values dynamically passing from run time it should be namespace.pkg1/namespace.pkg2  )
		Logger	logger = LogManager.getLogger("loggername");
		logger.info("testing");
		System.out.println("Hello");
			
	}

pkg1 log4j1 File

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
	<File name="A1" fileName="/app/opt/sag/webmethods/SITISA/IntegrationServer/instances/default/packageLogs/pkg1.log" append="true" MaxFileSize="5MB" MaxBackupIndex="10" >
      <PatternLayout pattern="%d %-5p [%t] - %m%n"/>
    </File>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="namespace.pkg1" level="info">

	    <AppenderRef ref="A1"/>
	    <AppenderRef ref="Console"/>

    </Logger>
  </Loggers>
</Configuration>

Pkg2 log4j2 File:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
  <Appenders>
	<File name="A1" fileName="/app/opt/sag/webmethods/SITISA/IntegrationServer/instances/default/packageLogs/pkg2.log" append="true" MaxFileSize="5MB" MaxBackupIndex="10" >
      <PatternLayout pattern="%d %-5p [%t] - %m%n"/>
    </File>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Logger name="namespace.pkg2" level="info">

	    <AppenderRef ref="A1"/>
	    <AppenderRef ref="Console"/>

    </Logger>
  </Loggers>

Hi,
Can you try with this xml file?

Change the file path in the log4j2.xml file. keep everything in the xml file and just invoke the logger property Name in the java code.

Java code is,

Java code:
image

Hi Maheshwari,

Its not working for me,did you tried with two logger names(ie two packages.).if so could you please tell me what are the steps you did.

Hi @sarankumar.kannan,

The issue you’re running into could be related to class loading (see Reverb) As described in the documentation, more specifically in the “Class Searching Order” page, the IS will search for classes (and other resources) in the server classpath first, then locally within the package, and then in all the required packages. Your custom package may be loading the incorrect Log4J configuration file due to this search order. You can easily test this theory by adding the following to your packages manifest.v3 file and reloading the package (or restarting the server):

<value name="classloader">package</value>

I had a very similar issue when moving a customer’s logging package (built on Log4J) from 10.3 to 10.11. In this package, the LoggerContext is initialized with:

context = Configurator.initialize(CONFIG_NAME, null, CONFIG_FILE);

… and although this worked fine in 10.3, in 10.11 the wrong Log4J configuration was being picked up. Adding the line above to the package’s manifest file caused the proper configuration to be picked up without code changes. There are code alternatives to this solution as well if changing the manifest file is undesired.

Hope this helps,
Percio

Hi everyone,

Can you please help me to use to shared folder path in the log4j properties File? How to configure or change the file path to use the shared folder.

Old Property file :

<Properties>
    <Property name="FileName">D:/Logs/ESB_${hostName}.log</Property>
<Property name="FileNamePattern">D:/Logs/ESB_${hostName}-%d{yyyy-MM-dd}-%i.log</Property>
<Property name="LogPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Property>
</Properties>

New PropertyFile using shared folder path:

<Properties>
    <Property name="FileName">SharedFileHostName/SharedFileuserName/SharedFilePassword/D:/Dev-Logs/ESB_${hostName}.log</Property>
<Property name="FileNamePattern">SharedFileHostName/SharedFileUserName/SharedFilePassword/D:/Dev-Logs/ESB_${hostName}-%d{yyyy-MM-dd}-%i.log</Property>
<Property name="LogPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Property>
</Properties>

Old PropertyFile is working fine with the filename, but when i change the filename to shared folder location, it is not working? Someone help me on this.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.