I am trying to run a jar as a windows service using Apache Commons Daemon(procrun). the services don't produce logs and not reading the config file.
The jar has started successfully. I am using log4j for logs in my jar and have included the log4j.properties in MyJar.jar. Yet the service is not creating any logs. And also I found that the program is not reading the config file - myConfig.config
I installed the service using the following command:
%INSTALL_SERVICE_CMD% //IS//SERVICEAGENT --DisplayName="DispName" --Install=%SERVICE_EXE_HOME%\prunsrv.exe --LogPath=%INSTALLER_HOME% --LogLevel=Info --StdOutput=stdout.log --StdError=stderr.log --StartMode=Java --StopMode=Java --Jvm=auto --Startup=auto --JvmMx=512 ++JvmOptions=-XX:MaxPermSize=128m --StartPath=%START_CLASS_PATH%\ --Classpath=absolutePath\MyJar.jar --StartClass=com.jar.aa.MainEntry --StopClass=com.jar.aa.ExitEntry ++StopParams=--stop ++JvmOptions=-Dfile.encoding=UTF8 ++JvmOptions=-Dlog4j.configuration=log4j.properties ++JvmOptions=-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
After running the service it produced the following:
stderr.log
2019-06-26 13:31:06 Commons Daemon procrun stderr initialized
log4j:WARN No appenders could be found for logger (com.facilio.bacnet.DiscoverDevices).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I want my code to read the config file and create logs appropriately. Everything works fine if I run the jar directly. The problem occurs only when I am running the jar as a service using Apache Commons Daemon Procrun.