Storage size in chainsaw v2 - java

I have a java application now i want to infrastructure monitor for my application logs at run time. I am using log4j for logging.I have filtering(monitoring) logs with chainsaw v2.Its working fine but my concern is how much logs data showing in chainsaw log console. please give me any suggestion.

I finally found the answer storage of chainsaw buffer size is 5000(means 5MB) goto view->show application-wide preperences -> general -> cyclic buffer size. you can see the image below

Related

Android. Alternative way for logging Application Output

I'm currently working on an App, which writes millions of lines to logcat (debugging output). I catch all these Informations (at runtime) by filtering the logoutput (of logcat) and write all the information in a file (redirect locat to a file). Unfortunately this takes very long and therefore the app runs very slow.
Now I wanted to ask, if there is a way, how i could get all these information faster. Is it faster, instead of writing the debugging information to logcat, to directly write the information to a textfile (on the device), or does anyone know a better way to gather these lines more efficient??!.
Thanks for reading,
greetings B.
There exist multiple logging tools. I recommend having a look at Timber trees.
But please listen on Jake Wharton:
Every time you log in production, a puppy dies.
Here is a list of logger tools from awesome-android:
logger - Simple, pretty and powerful logger for android
timber - A logger with a small, extensible API which provides utility on top of Android's normal Log class.
LoggingInterceptor - An OkHttp interceptor which pretty logs request and response data.
Bugfender - Upload your logs and check them online, specially made for mobile
EzyLogger - Simple Lightweight logger
Logback Android - Logback port to Android which provides a highly configurable logging framework for Android apps.
Punt - cli tool that makes adb logcat better

can Log.d("","") Logs, be seen in smartphone after installation?

If you use Log.d("hussi","hussi"): then we can see it in logcat .
but after the application is installed in the smartphone ,
can we see the logs somewhere in the phon , if yes , then where ??
also if there is any other way to write logs which we can trace in smartphones ?
If you need the Log details as text or xml format and will be stored in SD card.
You should use
https://code.google.com/p/android-logging-log4j/
Log4j Implementation in Android give you desired result.
You can use Log.debug(),log.error(), log.info()
All kind of log you can store in text or xml file.
Hope this will help you.
From the manual (emph mine).
Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.
Using this should print the logcat output to a text file:
Runtime.getRuntime.exec("echo logcat >> /sdcard/log.txt");
You can use logcat for the same. Samsung ships with an application to take log dumps. You can access it using the keystring *#9900# . Take log dumps from there and save it to sdcard for using later. AFAIK this behavior is Manufacturer specific.

Java logging in client application

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.

Java app startup with computer and be able to see system.out.println?

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 !!!

Best way to interact with application logs output from log4j (while also are being updated by application)

May be it is simpler than I think but I am confused on the following:
I want to be able to present to a user (in a graphical interface) the logs produced by Log4j.
I could just read the files as it is and present it, but I was wondering if there is a standard way to do it to so as to also get any updates that happen at the same time from the other parts of the application that log concurrently.
The log4j files could be multiple i.e. rolling appender
Also the presentation could be while there is no logging happening.
I.e. view of logs up to date
UPDATE:
I am constraint to Java 6
You can use Java 7's NIO2 libraries to get notified when one of multiple files get's modified in a directory, and reread & display it:
http://blogs.oracle.com/thejavatutorials/entry/watching_a_directory_for_changes
Have you tried the following tools :
Chainsaw
Xpolog
Perhaps add a database appender (JDBCAppender) and present the log entries from that?
Fro the official documentation of log4j:
Is there a way to get log4j to automatically reload a configuration file if it changes?
Yes. Both the DOMConfigurator and the PropertyConfigurator support automatic reloading
through the configureAndWatch method. See the API documentation for more details.
PropertyConfigurator#configureAndWatch
DOMConfigurator#configureAndWatch
For the on-demand reload of log4j config using GUI I would suggest expose it via a servlet in your J2EE application so that whole file can be edited in a web page (text area may be) and once saved you can overwrite your existing log4j file and reload the log4j config.
Maybe you could think about more "OS-level" solution.
I don't know if you are using win or linux, but on linux there is this realy nice command "tail".
So you could use ProcessBuilder to create OS process which goes something like "tail -f yourLogFile.txt".
And then read the OutputStream of the returned Process. Reading the stream will block waiting for new output from the process to be available, and will immediately unblock when such is available, giving you immediate feedback and possibility to read the latest changes of the log file.
However, you might have problems shutting this process down from Java.
You should be able to send SIGTERM signal to it if you know the process id. Or you could start a different process which could lookup the id of the "tail" process and kill it via "kill" command or something similar.
Also I am not sure if there is similar tool available on windows, if this is your platform.
If you write your own simple appender and have your application include that appender in your log4j configuration, your appender will be called whenever events are written to other appenders, and you can choose to display the event messages, timestamps, etc. in a UI.
Try XpoLog log4j/log4net connector. It parses the data automaticly and has predefined set of dashboards for it:
Follow the below steps
Download and install XpoLog from here
Add the log4j data using the log4j data connector from here and
deploy the log4j app here

Categories