Spring Boot log file not being created - spring-boot

I have a spring boot app (1.5.10.RELEASE) that logs great when running as a standalone application in Eclipse IDE. I am using spring config and the properties file says this:
logging.level.com.myco.impl=DEBUG
logging.path=/log/myService
When I run as a standalone application, I see everything I see logged to the console and to a file in the above directory (called spring.log).
I then build my "uber jar" and run in like this:
java -jar my-service-0.1.0.jar. I see all the console logging just like running in IDE. I can see it looking for my configuration in spring config but I do not see any log file created.
I could use some ideas on what to look at.

In short - I (almost :-) ) believe that you have not set proper permissions on the logging path as pointed in the comments. The logging configurations seem quite simple and are described here. You can't get these wrong easily and yours seem OK.
The tricky part is how to diagnose the exact problem. For example on my system if I change the owner of the logging directory I can reproduce the behaviour with the uber jar that you described.
Next - I guess we both use slf4j with logback (e.g. coming because of spring-boot-starter). The laziest and quickest approach to understand what's wrong is to print the logback status messages as explained here. For example - programatically - there are other options too but I'll take the dirtiest :-) . Put this somewhere in your code:
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
// print logback's internal status
StatusPrinter.print(lc);
LOGGER.debug("Some other message");
If I do that in my sample app (boot 1.5.10.RELEASE) I can immediately see the problem printed in the console along with many more status messages:
23:23:07,857 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(/tmp/so/spring.log,true) call failed. java.io.FileNotFoundException: /tmp/so/spring.log (Permission denied)
at java.io.FileNotFoundException: /tmp/so/spring.log (Permission denied)

See comments above. I did not include a jar I needed that was critical for reinitializing the logging system once it contacted spring cloud.

The issue may be a bug in Spring Boot 1.5.10, see:
https://github.com/spring-projects/spring-boot/issues/11951
I've faced similar issue when application cannot run, because log file was owned by root user and not available to change by application user.
Try to upgrade Spring Boot to 1.5.11 -- issue fixed in this version.

Related

JOOQ LoggerListener extensive DEBUG logging

I need, for performance reasons, get rid of org.jooq.tools.LoggerListener DEBUG log messages in Spring Boot application running inside Docker. None of the Spring Boot options like (Docker) env variable LOGGING_LEVEL_ORG_JOOQ=INFO in docker-compose.yml or Java system property -Dlogging.level.org.jooq=INFO passed to docker container in entry.sh do not remove these DEBUG messages reporting query execution details. Both option have been checked at Docker container level.
Even custom logback-perf.xml conf file, as in https://github.com/jOOQ/jOOQ/blob/master/jOOQ-examples/jOOQ-spring-boot-example/src/main/resources/logback.xml with DEBUG->INFO, pointed by LOGGING_CONFIG env var from docker-compose.yml does not prevent these debug messages. I have verified that the custom logback-perf.xml conf file is in use by changing appender patterns.
The best way to remove those messages in jOOQ directly, is to specify Settings.executeLogging = false, see here.
Obviously, there are also ways to set up loggers correctly, but I cannot see what you did from your description, or why that failed.

Duplicate log entries with spring boot logback

In our projects we have a strange problem with duplicate log entries in the log file.
We have multiple appenders but a single logger.
If the spring boot application is started on local machine using java -jar the problem is not reproducible.
The problem occurs only when the application started as a service.
How can i solve the problem.
The problem occurs only if a file appender configured and if the spring boot application started using /etc/init.d/ symlink.
The spring boot's default start script redirects all console logs into the configured log file.
As a result both the logback logger and start scripts writes in the same file, thus we see duplicate entries in the log file.
Using systemctl (or setting the LOG_FILE or LOG_FOLDER environment variables) will solve this problem.
If you cannot switch to systemd you can set the environment variables so that all stdout&stderr messages redirected to /dev/null:
export LOG_FOLDER=/dev
export LOG_FILENAME=null

Tomcat manager deployement via context file fails

I'm trying to deploy a web app via tomcat manager by only specifying the context file, as described in the tomcat 7 documentation at http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Deploy_A_New_Application_from_a_Local_Path.
I'm issuing the following call to the manager http://myhost.mydomain.com:8080/manager/text/deploy?config=file:/opt/company/product/conf/mycontext.xml
The context file looks like the following :
<!DOCTYPE project>
<Context path="/myapp" docBase="/opt/company/product/lib/myapp.war" antiResourceLocking="false" >
</Context>
And the manager indicates an error : FAIL - Invalid context path null was specified.
Now I can deploy the app if I use the call that also provides the deployment url (path). However I would expect Tomcat to read my context file and determine by itself the path from the file definition.
Is this an issue in the tomcat 7 manager and is there a way of bypassing this ?
Thanks for any pointers
As far as I can tell this is a bug with Tomcat (see comment from #devlearn).
To work around this limitation, I ended up relying on the Tomcat restart to do the initial deployment. Once Tomcat is aware of the application, then I can redeploy at will by stopping the application context, deleting the folder in webapps and manually unzipping the WAR file into a new folder that replaces the one I deleted. Ansible does all this work - I can revert back to using the Tomcat API when this bug is fixed.

Error running Spring Batch Admin on Tomcat 6/7

I am getting this error when running a Spring Batch Admin template project created via STS 3.2 on vanilla Tomcat 6/7 on RedHat Linux:
Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [batch-L.properties] cannot be opened because it does not exist
I have no idea where that file is coming from. I tried searching for the file but to no success. Also, I need to add, that when running the same *war file on my local machine, everything works fine.
I will be grateful for any help.
Spring Batch Admin uses a system variable ENVIRONMENT to determine what properties file to load. By default, (if the variable isn't set), it will look for an HSQLDB version named batch-hsqldb.properties. In your case, it looks like the ENVIRONMENT variable is being set to the letter L.

Weblogic error: ServletContainerAdapter manager not initialized correctly

I am new in Weblogic server, I am using Jdeveloper along with weblogic, but after launch the weblogic server i got the following error.
ServletContainerAdapter manager not initialized correctly
I am unable to run any web application. Please help me how to resolve that issue.
I googled about this topic and always get these adviced:
This error can be safely ignored in the development environment
change log4j.properties
Please check following property:
WL_HOME\server\lib\consoleapp\consolehelp\WEB-INF\classes\log4j.properties
The first copy this file for back-up. After try to set following adjust:
log4j.logger.org.apache.beehive.netui.pageflow.internal.AdapterManager
= FATAL
The weblogic documentation say:
This message is emitted from one of the frameworks used by the console
and can be ignored.

Resources