Is there a way to log Java runtime errors/exceptions in a PhoneGap/Cordova mobile application.
I just want to be able to see what is going on during execution. I'd like to store exceptions to a text file and then have the file sent back to me.
Thank you
Related
My setup:
Red Hat with:
Weblogic installation which hosts my (java) application.
What I try to achieve:
See the output (an error) of my application
Why I this way and not easier (set proper logging on the application itself):
This is a production server of a big company, I am not allowed to do any changes to the running applications
In the application something goes wrong and I am tasked with fixing it.
I checked the weblogic logs but they dont capture all the output of the application, and thus it does not capture the error im searching for.
So is there a way I can sort of connect to stdout/stderr and see the output printed live? (other suggestions are also most welcome but if its possible this seems like the easiest way to go?)
Extra info:
I have checked and confirmed the application writes to console, so it should appear in stdout. (right?)
Unless I misunderstand your question, you want to tail the logs.
Navigate to the directory where your logs are stored and run
tail -f LOGNAME.log
This should print to your console live any additional log lines that are added.
I've made a small desktop application in java for OS X. I've packaged in into a .app using JarBundler. Everything runs fine on my computer.
When I send the .app to someone else (also running a mac), the app opens and closes immediately. Is there a log file of some kind I can get from their computer (which I have full access to). Is there a way to get System.out.println statements or similar to show up in that file?
execute the application from the console, from there any errors will be printed to the standard error stream.
Please avoid using System.out.println() statements on the application. The method is synchronized and results in poor performance. Not to mention you may not be able to retrieve the statements based on who captures the console.
Use a logging solution like sl4j and back it up with a logger like log4j with a file appender. The file appender writes to a file and you can get your debug statements / stack traces from there.
I wrote a simple Java app which I have placed in the start up folder of my programs which makes the program starts when the computer starts up. what is the easiest way to make it open a command line or something which I can see the System.out.println results instead of just running in the background?
You should familiarize yourself with logging frameworks such as logback and log4j. Instead of using System.out.println you use some special API and the logging library redirects all messages to preconfigured appenders like console or file.
In your case you can configure your application to log on console while developing and switch to file when configuring an application to run from startup.
This won't really open a new command line window on startup, but instead it will store all messages to some predefined file on disk - which is actually even better.
You can use Log4j API for logging the details with the predefined outputs. It is far better then using SOP. Because it is light waighted and also very simple to configure the logs in the other files with the output format whichever you want to make.
http://logging.apache.org/log4j/1.2/ Go to this url where you can find log4j api available.
Hope this work for you
Enjoy !!!
I'm having some problems tracing the reason that I can't load a java(fx) applet.
The java plugin console for the browser has always been my sole source of information for problem solving. The reason it isn't much help at the moment is that the applet starts to load, downloading the jar files and outputting a percentage to the console along with the occasional statement to say it's on the next jar file. At some point in time (different percentages each time) the console just closes unexpectedly and the applet stops loading. I know this isn't much to go on but I was wondering if there was any way that the output from the console could be stored to a file on the local machine. To debug this particular problem, changing security permissions temporarily would be acceptable.
The problem has occured on every pc i've tried, however if I keep refreshing after failure it seems to cache the jar files previously downloaded and thus get further through the loading process until it eventually works. My issue now is that on a particular customers network refreshing does not resolve the issue. I thought it may be a permissions issue writing to disk but I've tried an administrator account and still no luck. I've also tried a variety of browsers. It might also be worth noting that they go through a proxy server - when the applet tries to load it asks for the credentials for logging on to the proxy which seems to authorise fine.
If anyone has a suggestion on what I could try it would be gratefully received.
Thanks,
James
Two points:
You should be able to get a stack trace through the applet console viewer (which runs in the system tray on PC's) and if you open that up it will show you your stack trace for debugging.
Can you reproduce this problem using the Java Applet Viewer tool? This will allow you to write unit tests, and debug much more easily.
I forget where it is, but somewhere in the java control panel (one of the options under the advanced tab I believe) there's an option to turn on logging. This will log all output to the java console to a file as well. I've used this when trying to debug issues similar to this.
There's some info here on where the files will appear:
http://download.oracle.com/javase/1.5.0/docs/guide/deployment/deployment-guide/tracing_logging.html
The problem ended up being some JS code that was making calls to the applet before the applet had initialised.
Do you know any good crash reporting systems for Java or any open source projects which use a crash reporting system?
Starting from simple
In case you want to report errors and exceptions to user in Java Swing Application htere is a nice library zeus-jscl that has several useful components:
gr.zeus.ui.JMessage - Displays simple messages and the stacktrace of an exception and more
gr.zeus.ui.JConsolePane - A java console to replace the command line window. Redirects the stdout and stderr etc.
This is sent nowhere it just locally convenient.
All of this brings me to how handles unhanded exceptions that occur in the wild. NetBeans pops up this little dialog and asks you to send in your report. Once you do send it, it's almost magical, reports are queued, analyzed, associated to either a new report or an existing report and finally the generic reports are associated to an issue in IssueZilla and it does it all automatically. If the issue is fixed, it even tells you in which, upcoming or not, version it has been fixed.
from here
You can download sources of NetBeans and rip off what you need. Read here how
The crash dump is just a text file. You could write a script which repeatedly runs your problem and mail you/notifies you of any new crash dumps.