Logging configuration completely ignored in Config.groovy when deployed as a war? - grails

When I run my application with run-app, logging seems to work correctly. When I deploy as a WAR in tomcat, all my logging configuration is ignored, and I only see
LOGLEVEL logmessage
Example:
INFO Hello world
What could possibly be causing this? I tried deleting tomcat's logging.properties, but that didn't seem to do anything.

Even after wiping the logging entirely, I still see this in catalina.out, while my logs to a log file are written correctly. A plugin or library, likely, is screwing up my logging, but tracing it down at this point isn't worth it.

Related

migration from log4j1.x to log4j2

we are trying to migrate log4j version 1.x to 2.x because of log4j vulnerability. but after migration logs are not getting printed as previous. we have on file in which all console logs (system out) get printed and we have another file which uses TimedRollingFileAppender through java code to write to a file (this appender is in java note in log4j2 xml). but with log4j2 all logger logs coming into console file as well, which is supposed to write only system out logs. when we remove log4j2.xml file all logs comes in debug mode in both the files and when we provide log4j2.xml all logs come in Error mode in both files. we are blocked, anyone can please help here.

How to Tell Engine Yard to Not Delete a File in the .gitignore

To give you some context, I'm trying to use Figaro to safely add in environment variables without having to worry about security risks. The problem is is that I can't seem to get Engine Yard to play nice with production.
I went and did a touch application.yml and then vim application.yml, i, and then command+v to insert that api keys and what not. I know the ENV['VARIABLES'] work because of development and all my rspec and cucumber tests (which utilize the APIs), passed.
When I've got everything ready, I add within the .gitignore:
# Ignore application configuration
/config/application.yml
Afterwards, I deploy the site. I open it up and data isn't going to the APIs anymore. OK...
cd into config and discover application.yml isn't there anymore. Paste it back in... Redeploy the site since now it understands it has to ignore that file and I'm not seeing changes on production. Check back... and its gone again!
Stumped on what's going on.
Simply putting a file into your deployed application's filesystem will not work because you get a clean environment each time you deploy. EngineYard cannot know that you want that particular file copied to that particular location without a little bit of extra work.
Their official recommendation is to put your YAML configuration files in /data/<app>/shared/config and symlink them to /data/<app>/current/config each time you deploy using deploy hooks.

My new password page says 404 in production mode only

http://site.com/users/password/new is returning a 404 in production mode but not in development. I am deploying via capistrano and it looks like it's copying the entire site over properly. I tried running the console in production mode on the server and couldn't find anything. Has anyone seen this before?
Since this path works in development and fails in production I would focus on the differences between your environments.
A common issue is that people commit their changes locally, but do not push them to (e.g.) GitHub before deploying with capistrano. Can you ssh into your server and go to the current path and run rake routes there? Try and check if there are differences.
Once you've confirmed that at least the routes on the server are up to date, try checking the production log while accessing /user/password/new. It should be in /shared/log/production.log. You could ssh there and use tail -f production.log to follow the log while you try to access the path.
On a side note, it seems that you are using Devise. There have been similar issues for the user root path. See for example this question. Perhaps this will shed some light on your problem.

My Rails app is returning HTTP 500 for all its URLs, but nothing shows up in the log file. How can I diagnose the problem?

I have a Rails app that is running on a production server with Apache and Phusion Passenger. The app works fine locally when using Mongrel, but whenever I try to load a URL on the production server, it returns HTTP 500. I know the server is working properly, because I can get the static elements of the application (e.g., JavaScript files, stylesheets, images) just fine. I've also checked the Passenger status and it is loading the app (it must be, since the app's 500 Internal Server Error page is returned, not just the default Apache one). Also, when I load the app via script/console production and do something like app.get("/"), 500 is also returned.
The problem is that there is nothing in the log files to indicate the problem. production.log is empty. The Apache error logs show no problems with Apache, either. I'm stumped as to what's going on and I'm not sure how to diagnose the problem.
I know I may have been a bit vague, but can anyone give a suggestion on what the problem may be? Or at least a way I can go about diagnosing it?
The answer for this specific situation was a problem with my app. One of the model classes used a different database connection than the rest of the app. This database connection was not configured properly. I think the reason why nothing was written to the log files is that Rails bailed out without having any idea what to do.
Since it may be helpful for others to see how I diagnosed this problem, here was my thought process:
The issue couldn't be with Apache: no errors were written into the Apache log files.
The issue probably wasn't with Passenger: Passenger wasn't writing any errors to the Apache log file, and it seemed to be loading my app properly, since passenger-status showed it as loaded and it was display my app's 500 Internal Server Error page (not the default Apache one).
From there I surmised that it must be something broken in my app that happened very early on in the initialization phase, but wasn't something that caused the app to completely bail and throw an exception. I poked around in the Phusion Passenger Google Group, and ultimately stumbled upon this helpful post, which suggested that the error may be a database connectivity issue. Sure enough, removing this misconfigured database and all references to it made the app work!
Have you tried running the app locally using Passenger?
Try running the application locally on Mongrel in Production mode, to make sure that there's no weird issues with that particular environment. If that works, then you know that it's not an issue with your codebase. Since your static components are being served properly, that tells me that Apache is working fine. The only gear in the system left is Passenger. At this point, I would say it's an improperly configured Passenger. You should post up your Passenger config file, and ask the question on ServerFault.
A couple of things to try :
Have you gone though the following from the docs:
6.3.7. My Rails application’s log file is not being written to
There are a couple things that you
should be aware of:
By default, Phusion Passenger runs Rails applications in production
mode, so please be sure to check
production.log instead of
development.log. See RailsEnv for
configuration.
*
By default, Phusion Passenger runs Rails applications as the owner
of environment.rb. So the log file can
only be written to if that user has
write permission to the log file.
Please chmod or chown your log file
accordingly.
See User switching (security) for details.
If you’re using a RedHat-derived Linux
distribution (such as Fedora or
CentOS) then it is possible that
SELinux is interfering. RedHat’s
SELinux policy only allows Apache to
read/write directories that have the
httpd_sys_content_t security context.
Please run the following command to
give your Rails application folder
that context:
Have you checked your vhost or httpf.conf file ? Do you have any logging directives ?
Check the top level apache log file
Try setting PassengerLogLevel to 1 or 2 or 3, as shown here http://www.modrails.com/documentation/Users%20guide.html#_passengerloglevel_lt_integer_gt
Do you have any rack apps installed ?
My suggestion would be to go right back to "Hello World" land and create the smallest possible Ruby example application and upload it to see if there is a problem with Passenger or Ruby on the server.
May be a silly suggestion but I suggest you start by increasing the logging levels on production while you are testing. Do this in config/environments/production.rb and use:
config.log_level = :debug
This should at least get you some sort of backtrace so you can start to find the problem.
If you still get nothing - you may find that you have an issue with something as simple as a missing gem/plugin on your production server. That sort of thing may well manifest as a "500" error and just not be very verbose for you.
Can you run the test suite on your production server?

Where are the logs for a Rails app packed using Warbler?

I'm using Warbler to pack a Rails application into a WAR. I've deployed it to a JBoss server and it seems to works.
However, I'm getting the classic 500 error on Rails saying "We're sorry, but something went wrong.".
Usually, I'd take a look at logs/production.log to find out what's wrong, but since the project is WARed, I can't access it. The question is, where are the logs written when the Rails app gets warbled?
JRuby-Rack, the servlet container adapter that Warbler bundles, is set up by default to redirect Rails logs to the servlet container using the javax.servlet.ServletContext#log method. So exactly where the logs appear is server-specific. For Tomcat, they should be in catalina.out, for GlassFish, server.log.
If you still don't see error messages in the log files, there could be a bug somewhere along the way that is swallowing the error. Feel free to open a problem report for JRuby-Rack at http://kenai.com/jira/browse/JRUBY_RACK.
Although this question is pretty old and has been answered already, but I had been facing similar issue with Sinatra application which was warbled and deployed in Tomcat. The catalina.out (or tomcat logs folder) was not spitting out the logs at all. I finally found that the logs reside in the deployed application's WEB-INF folder itself.
For example
{TOMCAT_BASE}/webapps/{WEB_APPLICATION_PATH/WEB-INF/log/production.log
This had been a mystery to me for quite sometime.

Resources