Logs don't show up under Google App Engine project console - java

I'm struggling with this basic stuff for weeks already.
Can't make simple logs working in my Google App Engine (JAVA) app.
I started from this tutorial. Looks pretty straight forward.
Inside my Endpoint class I've defined a Logger like this:
private static final Logger log = Logger.getLogger(GowMainEndpoint.class.getName());
Then in one of my endpoint methods I tried to log event like:
log.info("test");
There is nothing showing up in logs. I have logging.properties file and appengine-web.xml configured just like in the mentioned tutorial.
EDIT: Weird thing: log.warning("test"); is showing up logs...

Ok I figured it out:
in the logging.properties file I've changed
.level = WARNING
to
.level = INFO
The comment line says:
# Set the default logging level for all loggers to INFO
but now I got the feeling it should be more like:
# Set the MINIMUM logging level for all loggers to INFO

Related

Logs are not populating with Log4j 2.17.2

We have older java code which was using log4j 1.17 and application logs were writing to log file properly. As part of vulnerability fixing we have to migrate to log4j 2.17.2 (Mandatory as part of compliance). We have followed the migration plan as per the Apache blog- https://logging.apache.org/log4j/2.x/manual/migration.html
So, now we have added the reference of log4j-1.2-api-2.17.2.jar, log4j-api-2.17.2.jar and log4j-core-2.17.2.jar files instead of log4j-1.17.
But, with log4j-2.17, no logs are populating in the log file....though application is running and functionalities also working....but no logs in the log file.
As soon as we refer the log4j-1.17, log files are starts populating. I am not able to figure out what is going wrong here.
Below is how the logger was instantiated in old code-
static Logger log = Logger.getLogger(SendApproverDetails.class);
Log4j.Properites files details-
Updated the log4j.properites file with
#PiotrP.Karwasz suggestion. Still no luck-

Eclipse console doesn't show Tomcat exceptions/stacktrace

When I start Tomcat from within Eclipse, I get a console with logging information which are very much what I am used to, they always end with the statement that Tomcat was launched within n milliseconds.
However, whenever an exception occurs, the stack trace for this Exception does not show up in the console. I was used to be able to see them "happen" right from the IDE.
Setting the level in logging.properties to a different value (FINEST or ERROR) brings up the expected changes, but stil no log entry for Exceptions whatsoever.
Does Tomcat log Exceptions in a different way?
The HTTP 500 message mentions the Tomcat logs. So there should be a place where much more info is sent to.
The respective log directories only contain simple access logs and what I see on the console in Eclipse.
Which configuration is responsible for the output to the console?
My logging.properties looks like this:
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = FINE
org.apache.catalina.level=FINE
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
Wich logging implementation are you using? in logging.propertie you are configuring apache log. To user pure java log, try to configure programmatically, something like this:
static Logger logger = Logger.getLogger(YourClass.class.getName());
System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: [%1$tc] %5$s %n");
//Creating consoleHandler and fileHandler
consoleHandler = new ConsoleHandler();
LOGGER.addHandler(consoleHandler);
//Setting levels to handlers and LOGGER
consoleHandler.setLevel(Level.ALL);
consoleHandler.setFormatter(new SimpleFormatter());
.. When you want to log, do this:
LOGGER.log(Level.FINE, "HELLO LOG");

app log file miss most log info when do concurrence testing

i use JMeter to do concurrence testing for web app.
environment : linux , JMeter 2.6, tomcat 6.0.35, log4j 1.2.14,
i use appender of my company which extends RollingFileAppender, it's used for creating corresponding log file according to the different user and login ip, e.g. user1-233.111-app.log.20121112
i set the threads of JMeter is 50, then run the jmeter script to test web app, there are 50 log files in tomcat/logs, but there are next problems :
each log file miss most log info, e.g. user1-233.111-app.log.20121112 only has one line info, but it should has much log info
user1's log file contains user2's log info, e.g. in user1-233.111-app.log.20121112, there are some lines like - INFO [user2] ..........
there is not user1-233.111-app.log.20121112.1, user1-233.111-app.log.20121112.2 etc
Thanks in advance!
This is surely a bug in your file appender extension class. Show code here so that you can get answer .

SLF4J logs error messages at info level

I'm running into a weird problem. I have a class that used to use Log4j, and I could do something like:
LOGGER.log(Level.SEVERE, "This is a message");
And I'd get output like this:
SEVERE: This is a message
I replaced it with an SLF4J logger for consistency with the rest of the application:
LOGGER.error("This is a message.");
But now it's logging at INFO level:
INFO: 2012-01-23 16:50:43,306 [http-thread-pool-8080(3)] ERROR com.mycompany.MyClass - This is a message
I was expecting this to be logged at ERROR level (SLF4J doesn't seem to have any levels above that).
Any idea what's going on? Is this the default? The application is fairly complicated, so I wouldn't be surprised if this was changed somewhere, but where would I find that to change it back?
I'm using Glassfish, in case that might be related.
you need to make your SLF4J use the Java Util Logging backend. That's what Glassfish uses internally. Since it's not using that, it's dumping to the console, and GF reports everything on the console as INFO.
So hook up the JUL adapter and you should be all good.
without configuration listing for logging it's only a guess. but I think the logging framework is probably misconfigured. slf4j logs at ERROR level:
ERROR com.mycompany.MyClass - This is a message
then this output is sent into console, which is redirected into general log file at INFO level by glassfish.
previous setup probably used glassfish logging directly inheriting its configuration. after switching to slf4j no config was found so everything is sent to console and then to server.log

Google App Engine - Can not find my logging messages

I can not find the results of my logging calls.
To log messages I tried both:
System.out.println("some message");
and
Logger logger = Logger.getLogger("MyLogger"); // Logger is java.util.logging.Logger
// ...
logger.info("some message");
I have deployed my app and after few tests I decided check out some
log messages. But there were no messages. I changed minimum severity
level to "Info" from default "Error", and only messages i've seen were
service messages like this:
http://dl.dropbox.com/u/1678938/logs.png
I would also be grateful if someone show a little snippet with logging some data (if it's works) - I suspect my problem may be the one of that stupid problems when somewhat incorrectly located comma can be the cause of situation.
Could it be that your logging.properties is setting the default value to WARNING?
Ours has this in our war/WEB-INF/logging.properties file:
# Set the default logging level for all loggers to WARNING
.level = WARNING
# Default level for subpackages of 'server' will be INFO
com.company.whatever.server.level=INFO
Problem has shrunk into more concrete form - App Engine "eats" info-messages, but shows others, such as error and warning messages.
After this call I have eventually seen my info messages:
log.setLevel(Level.INFO);
But it is still not clearly - why info-messages weren't being shown. Google's manual states:
Everything the servlet writes to the
standard output stream (System.out)
and standard error stream (System.err)
is captured by App Engine and recorded
in the application logs. Lines written
to the standard output stream are
logged at the "INFO" level, and lines
written to the standard error stream
are logged at the "WARNING" level.
Had exactly the same problem and after changing the value in logging.properties from
.level = WARNING
to
.level = INFO
The problem was definitively fixed. Google needs to update their documentation and/or change the value of the supplied default so that "INFO" log messages don't get swallowed.
I used to set LEVEL to SEVERE for testing
logger.log(Level.SEVERE, "test message");
It does not need changing any value in logging.properties

Categories

Resources