How do I change the default location for mule application log files? - mule

I would like to change the log directory from MULE_HOME/logs to MULE_HOME/logs/apps. The only place I have found that refers to a file path is in MULE_HOME/conf/wrapper.conf. Editing the wrapper.logfile does allow me to relocate the mule_ee.log file, which seems to be the Mule application log, but I'd like to include Mule application logs there, too. If I create an application called FOO and deploy it to the runtime environment, it will create a file called MULE_HOME/logs/mule-app-FOO.log, but changing the location seems to be difficult short of completely messing things up writing custom log4j2 XML files.

If you have Mule version 3.6+, then it is recommended to use log4j2.xml instead of log4j.xml.... Using log4j2 you can change the path and get your application log ... a simple example would be :-
<RollingFile name="RollingFile" fileName="${env:MULE_HOME}/logs/${sys:CustomapplicationName}.log"
filePattern="${env:MULE_HOME}/logs/${sys:CustomapplicationName}-%d{yyyy-MM-dd}-%i.log"> <!-- CustomapplicationName is set at mule-app.properties or in VM argument in Run As Configure as -DCustomapplicationName=Log4j -->
<PatternLayout>
<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="120 KB" />
</Policies>
<DefaultRolloverStrategy max="1" />
</RollingFile>
Just put this above code in your log4j2.xml in src/main/resource folder
Here in above you can see that, you have configured your path of your log files by mentioning here:-
<RollingFile name="RollingFile" fileName="${env:MULE_HOME}/logs/apps/${sys:CustomapplicationName}.log"
filePattern="${env:MULE_HOME}/logs/apps/${sys:CustomapplicationName}-%d{yyyy-MM-dd}-%i.log">
where ${sys:CustomapplicationName} is the System variable set in mule-app.properties as following :-
CustomapplicationName=yourApplicationName

Right way is to have log4j properties / xml file for FOO application and have that define the desired path for FOO application log. This way will ensure mule_ee.log is not messed up and at the same time other applications too will have their own log files which will be easy to manage and easy to introspect specific application log in case of errors / exceptions

Define location in log4j.properties file.

Related

log4net log message does not contain method name

I am trying to include the method name %method in log messages when using log4net. However, if I look at the log output it only shows a ? where method name should be.
I know in reading the log4net docs that this is only available with System.Diagnostics.StackTrace and this should only be used in development and not release builds.
Trying to make this work in a .NET Core application using the Microsoft.Extensions.Logging.Log4Net.AspNetCore
and the call to .AddLog4Net(); in Startup
Here is the conversionPattern for the RollingFileAppender
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
I have put together a github repository with bare bone example of what I'm trying to get at. If you run the project you see the log file output does not contain method information.
Repository available at log4net-netcore-example
In reviewing various SO articles, I've not found the solution to this yet. I'm assuming I'm missing a configuration or maybe a nuget package required to make this work.
Appreciate any insights anyone can provide.

How to disable the OrientDb in Moqui

I am trying to run Moqui by dropping the war file into tomcat6, but it complains about OrientDb, which I don't need, so I would like to disable it.
I commented out the datasource reference in MoquiDefaultConf.xml but it still complains (SEVERE: Exception sending context initialized event to listener instance of class org.moqui.impl.webapp.MoquiContextListener
java.io.FileNotFoundException: /var/lib/tomcat6/webapps/offernanny/runtime/db/orientdb/config/orientdb-server-config.xml (No such file or directory)).
To disable OrientDB you'll need to tell the Entity Facade to use a different datasource for the "nosql" entity group. Here is an example snippet for the runtime Moqui Conf XML file (i.e. MoquiDevConf.xml, MoquiProductionConf.xml, etc):
<entity-facade crypt-pass="MoquiDefaultPassword:CHANGEME">
<!-- add datasource elements here to configure databases -->
<datasource group-name="nosql" database-conf-name="derby" schema-name="MOQUI" object-factory="">
<inline-jdbc pool-minsize="2" pool-maxsize="20">
<xa-properties databaseName="${moqui.runtime}/db/derby/MoquiTransactional" createDatabase="create"/>
</inline-jdbc>
</datasource>
</entity-facade>
This changes it to use the MoquiTransactional database, the same db as the "transactional" entity group.
Additional information for the other part of your question: the reason the runtime/db/orientdb/config/orientdb-server-config.xml file was not found was because it was not there. The gradle addRuntime task and ant add-runtime target were not copying the runtime/db directory. This is changed in commit #d3eebaa on the master branch, and OrientDB runs under Tomcat now with an embedded runtime directory.

weblogic hot deployment working for jsps but not for web-inf/classes

I am deploying an ear application in weblogic 10.3 in exploded format with fast swap enabled and in dev mode.
The ear file contains a web app also in exploded format. The changes made to the jsps in the web app are getting reloaded. But the classes under web-inf when changed are not reloaded.
The weblogic deployment configuration is given below.
weblogic-application.xml content in ear/META-INF
<wls:fast-swap>
<wls:enabled>true</wls:enabled>
<wls:refresh-interval>10</wls:refresh-interval>
</wls:fast-swap>
<wls:classloader-structure>
<wls:classloader-structure>
<wls:module-ref>
<wls:module-uri>web.war</wls:module-uri>
</wls:module-ref>
</wls:classloader-structure>
</wls:classloader-structure>
application.xml content in ear/META-INF
<display-name>web-ear</display-name>
<module>
<web>
<web-uri>web.war</web-uri>
<context-root>/web</context-root>
</web>
</module>
<library-directory>lib</library-directory>
weblogic.xml content in war/WEB-INF
<wls:fast-swap>
<wls:enabled>true</wls:enabled>
<wls:refresh-interval>10</wls:refresh-interval>
</wls:fast-swap>
<wls:context-root>/web</wls:context-root>
<wls:session-descriptor>
<wls:cookie-max-age-secs>-1</wls:cookie-max-age-secs>
<wls:cookie-name>JSESSIONID_SQE_AAI</wls:cookie-name>
<wls:cookie-path>/</wls:cookie-path>
<wls:cookies-enabled>true</wls:cookies-enabled>
<wls:invalidation-interval-secs>120</wls:invalidation-interval-secs>
<wls:id-length>52</wls:id-length>
<wls:timeout-secs>7200</wls:timeout-secs>
<wls:url-rewriting-enabled>true</wls:url-rewriting-enabled>
<wls:persistent-store-type>memory</wls:persistent-store-type>
<wls:http-proxy-caching-of-cookies>false</wls:http-proxy-caching-of-cookies>
</wls:session-descriptor>
<wls:jsp-descriptor>
<wls:page-check-seconds>6</wls:page-check-seconds>
</wls:jsp-descriptor>
<wls:container-descriptor>
<wls:servlet-reload-check-secs>6</wls:servlet-reload-check-secs>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
Is the configuration done above right? Are there any config details I have missed to include here? What other settings or configurations should I check?
Any help would be very much appreciated thanks.
Even if you enable FastSwap in your application, the modules that are declared in the classloader-structure will not support FastSwap because they aren't loaded by the RedefiningClassLoader, but rather by the GenericClassLoader.
You can test this by printing the classloader of your classes under WEB-INF/classes and check if it's the com.bea.wls.redef.RedefiningClassLoader or not.
I struggled to make them work together, you can see more details here https://forums.oracle.com/forums/thread.jspa?threadID=2476484&tstart=60 but, unfortunately, no solution so far.
Regards.

VelocityTools error - "java.util.MissingResourceException: Can't find bundle for base name WEB-INF.conf.resources.ss_messages, locale en_US"

I'm trying to integrate VelocityTools.ResourceTool to localize velocity template but whatever I use as the 'bundles' parameter I keep getting the following error:
java.util.MissingResourceException: Can't find bundle for base name
WEB-INF.conf.resources.ss_messages, locale en_US
I'm using VelocityTools v1.4. Here are my configurations:
Tool config /WEB-INF/conf/misc/velocity/toolbox.xml
<tool>
<key>test</key>
<scope>request</scope>
<class>org.apache.velocity.tools.generic.ResourceTool</class>
<parameter name="bundles" value="WEB-INF.conf.resources.ss_messages"/>
<parameter name="locale" value="en_US"/>
</tool>
Bundles:
\WEB-INF\conf\resources\ss_messages_bg_BG.properties
\WEB-INF\conf\resources\ss_messages_en_US.properties
The two files have simple content:
full.name=\u0421\u0442\ (for bg_BG.properties)
full.name=Joe Blow (for en_US.properties)
My Velocity template has this code:
HELLO $test.full.name
I tried different values for the name="bundles" above i.e., /WEB-INF/conf/resources/ss_messages and ./conf/resources/ss_messages (going to the root dir and then referencing the ss_messages bundle).
Also, I tried putting my ss_messages.properties bundle files in a resources folder in the root and use the value="resources" instead, but nothing seems to be working...still getting the same error message.
What am I doing wrong?! Is it that the toolbox.xml file is not in the root? I've been using successfully the toolbox.xml throughout my application up until now.
The resources should be on the classpath, and configured as such.
See the ResourceTool API docs.

Axis2 embedded in my web app is not working

OKay I lost alsmost the whole day on this.
I have a webapp where I would like to add AXIS2 and start working.
I added AxisServlets in the web.xml file like -
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
I also added Services.xml file like
<service name="ReportViewerService">
<description>
This is a sample Web Service for illustrating Attachments API of Axis2
</description>
<parameter name="ServiceClass">myclass</parameter>
<operation name="getReport">
<actionMapping>urn:getReport</actionMapping>
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
</service>
The directory structure is as mentioned here
WEB-ING
| - conf
| |- axis2.xml
|-lib
| |- all libs
|-services
|-ReportViewerService
| - META-INF
|-services.xml
|- web.xml
The problem is - after all of these, the service endpoint will not come, I can not see the WSDL file http://localhost:8080/BOReportingServer/services/ReportViewerService?wsdl -- this gives an exception like -
Throwable occurred: javax.servlet.ServletException: File "/axis2-web/listSingleService.jsp" not found
Finally I am able to embed AXIS2 in my webapp.
It is as simple as mentioned in the tutorial , only thing is:
I never got the jars properly placed under WEB-INF/lib directory.
Once I started from the very beginning and removed all the unwanted jars and duplicate jars from the WEB-INF/lib directory, so started working.
I had this same symptom when trying to deploy an axis2 service with a packed (unexploded) .war file on a tomcat server.
"Throwable occurred: javax.servlet.ServletException: File "/axis2-web/listSingleService.jsp" not found"
The solution was to add the 'services.list' file to the /WEB-INF/services/ folder.
(There is also a modules.list file for the /WEB-INF/modules/ folder.)
These are just a text files listing out the service archive files in the folder.
/WEB-INF
|-modules
|-addressing-1.6.1.mar
|-...
|-modules.list
|-...
|-soapmonitor-1.6.1.mar
|-services
|-ReportViewerService.aar
|-services.list
In the .list files, contain just the names of the archive files, one entry per line.
Reference: http://axis.apache.org/axis2/java/core/docs/app_server.html
You also deployed axis2.war in your servlet container, right?
In order for Axis2 to work properly, you need to deploy it to a servlet container. A tutorial can be found here. You'll know you've done it properly when the Axis2 "Happy" page can be shown.
Once you've done that, you should be able to bundle up your service (in the structure you've described above in your question) into an .aar file and deploy it using the axis2 servlet.