By standard, the Android logcat system have 4 different ring buffers:
main
system
radio
events
# and alias & groups:
all -- all available logs
default -- main
crash -- n/a
However, on AOS 6+ there seem to be other buffers as well:
# logcat --help
...
-b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',
'events', 'crash' or 'all'. Multiple -b parameters are
allowed and results are interleaved. The default is
-b main -b system -b crash.
...
and the android logcat.cpp source code, seem to imply there are still other ones, such as:
security
kernel
Normally in java apps, the way to put a message in main logcat is by using: Log.i(TAG, msg).
So the question is:
How does Android determine which buffer to use for the various logcat messages?
(Specific references to the AOS source code would be especially appreciated.)
Then a natural follow up question would be, how can you see or enable the other hidden buffers?
I don't like to answer my own questions, but I've found a few answers, and also some very good notes.
First, the various log related (Java) source files are located in:
platform_frameworks_base/core/java/android/util/ and in:
platform_frameworks_base/telephony/java/android/telephony/.
EventLog.java # EVENT Log: These diagnostic events are for system integrators, not application authors.
Log.java # MAIN Log: Where user app logcat goes from: Log.v() Log.d() Log.i() Log.w() and Log.e()
Slog.java # SYSTEM Log: Primarily for use by coding running within the system process.
Rlog.java # RADIO Log: All radio, wifi, bluetooth etc. related logs. Also scrubs personal info from appearing in logs.
with the related files:
EventLogTags.java # Deprecated! (Use EventLog)
LocalLog.java # log(), dump(), reverseDump(), ReadOnlyLocalLog()
LogPrinter.java # decides what buffer to print to: LOG_ID_<buffer_name>
LogWriter.java # decides priority and TAG
TimingLogger.java # A utility class to help log timings splits throughout a method call.
The log buffers are identified in Log.java by:
public static final int LOG_ID_MAIN = 0;
public static final int LOG_ID_RADIO = 1;
public static final int LOG_ID_EVENTS = 2;
public static final int LOG_ID_SYSTEM = 3;
public static final int LOG_ID_CRASH = 4;
In the OS, the logging is governed by the properties:
setprop log.tag.<YOUR_LOG_TAG> <LEVEL>
and in the file /data/local.prop by:
log.tag.<YOUR_LOG_TAG>=<LEVEL>
Furthermore, I found the interesting comments.
The MAIN log:
The order in terms of verbosity, from least to most is
ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled
into an application except during development. Debug logs are compiled
in but stripped at runtime. Error, warning and info logs are always kept.
Tip: Don't forget that when you make a call like
Log.v(TAG, "index=" + i);
that when you're building the string to pass into Log.d, the compiler uses a
StringBuilder and at least three allocations occur: the StringBuilder
itself, the buffer, and the String object. Realistically, there is also
another buffer allocation and copy, and even more pressure on the gc.
That means that if your log message is filtered out, you might be doing
significant work and incurring significant overhead.
The EVENT log:
Access to the system diagnostic event record. System diagnostic events are
used to record certain system-level events (such as garbage collection,
activity manager state, system watchdogs, and other low level activity),
which may be automatically collected and analyzed during system development.
This is not the main "logcat" debugging log ({#link android.util.Log})!
These diagnostic events are for system integrators, not application authors.
Events use integer tag codes corresponding to /system/etc/event-log-tags.
They carry a payload of one or more int, long, or String values. The
event-log-tags file defines the payload contents for each type code.
Related
I'm using IntelliJ IDEA to remote debug a Java CLI program with the debugger listening for connections.
This works fine for the first invocation, but the debugger stops listening after the CLI program disconnects. I want the debugger to keep listening since multiple CLI invocations will be made (in sequence, not in parallel) and only one of these will trigger the breakpoint I've set.
Here's my client debug config:
-agentlib:jdwp=transport=dt_socket,server=n,address=5005,suspend=y
Is it possible to keep the debugger listening?
Well since your CLI program terminates, debugger also stops. If you still want to continue debugger session for multiple runs of CLI program, then you can try as below,
Write a wrapper program from which you invoke your CLI program multiple times and debug the wrapper program instead of your CLI program.
Something like this,
public class Wrapper {
public static void main(String[] args) {
YourCLIProgram yp = new YourCLIProgram();
// First Invocation
String[] arg1 = { }; // Arguments required for your CLI program
yp.main(arg1);
// Second Invocation
String[] arg2 = { }; // Arguments required for your CLI program
yp.main(arg2);
// Third Invocation
String[] arg3 = { }; // Arguments required for your CLI program
yp.main(arg3);
// Fourth Invocation
String[] arg4 = { }; // Arguments required for your CLI program
yp.main(arg4);
}
}
I hope it works.
It depends also what you are trying to achieve.
If you want to check what parameters are passed to your CLI you can just log them to the file or save any information that you need in DB (or file as well).
In JPDA by specification transport service could support or not multiple connections.
For example, in Eclipse it doesn't. I suppose the same for IDEA.
When setting up your run configuration, did you select the "Listen" Debugger mode? The command line arguments you show look like the normal "Attach" settings, whereas the arguments for "Listen" look like this:
-agentlib:jdwp=transport=dt_socket,server=n,address=yourhost.yourdomain:5005, suspend=y,onthrow=<FQ exception class name>,onuncaught=<y/n> (Specifically, your arguments are missing the address for the application - your CLI program - to connect to IDEA at on start-up.)
I read a post that suggests the "onthrow" argument may not be necessary for general debugging, but I haven't tried it myself.
Try with suspend=n:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
On my local app (tomcat web app), even though I run on JDK8, I still use the older way of doing it and it works fine (another thing you could try):
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
I have the below constructor for my customized exception
public CoException(String errorMessage) {
super(errorMessage);
CoDebugger.debugException(errorMessage, this);
}
A static code analyzer tool (fortify) identifies vulnerability issue in this portion of code.
The message given by fortify is
"The method CoException() in CoException.java mishandles confidential information, which can compromise user privacy and is often illegal."
Please let me know where is the issue and how to fix that.
The tool makes a data flow analysis:
Incoming: String errorMessage - What error message could contain interesting information for an attacker? Let me think. Login failed: user=admin pwd=123456 would certainly be something that should be kept internally.
Outgoing: super(errorMessage); and CoDebugger.debugException(errorMessage, this); - What does the debugException method? Does it show the error message directly to the user? That should not happen. Or is the error message written to a log file which under certain conditions (e. g. by an incorrect .htaccess configuration) can be accessed by the user. That should also not happen, of course.
I have just installed dcm4chee4-4.4.0.Beta1, following INSTALL.md instructions and everything works fine except movescu test.
When I run this test I can see an error in standalone/log/server.log (previously I launched in another console storescp -b11115). This is the error:
2015-09-13 12:48:49,105 INFO [org.dcm4che3.net.Association] (pool-6-thread-7) DCM4CHEE<-MOVESCU(7): processing 1:C-MOVE-RQ[pcid=1, prior=0
cuid=1.2.840.10008.5.1.4.1.2.2.2 - Study Root Query/Retrieve Information Model - MOVE
tsuid=1.2.840.10008.1.2 - Implicit VR Little Endian failed. Caused by: org.dcm4che3.net.service.DicomServiceException: Unknown Move Destination: STORESCP#localhost:11115
at org.dcm4chee.archive.retrieve.scp.CMoveSCP.calculateMatches(CMoveSCP.java:184) [dcm4chee-arc-retrieve-scp-4.4.0.Beta1.jar:]
I think this is because of configuration, maybe I have to add STORESCP as acceptedAET or similar, but I can find info on how to do it. I search through ldap using Apache Directory Studio, but I didn't find anything.
Thanks in advance.
Using dcm4che3, it goes like this if you're implementing an SCP and need to define which other SCPs are allowed to C-STORE things to you.
// Usual calamity creating Connection, ApplicationEntity and Device
...
ApplicationEntity ae = new ApplicationEntity("MYAETITLE");
String[] acceptedAETs = { "STORESCP", "GEPACS" }; // etc...
ae.setAcceptedCallingAETitles(acceptedAETs);
I assume that your favourite SCP (STORESCP) may need to know where to find the SCP known by MYAETITLE; identified by IP address and port. Typically you connect to an SCP as a SCU, issuing a C-MOVE (in the scenario laid out here) instructing the SCP to do a C-STORE to the AET identified in the C-MOVE.
I'm a bit confused by your choice of AE Title in your question (STORESCP) because that indicates that you kind of mix up the two SCPs involved here; the one receiving the C-MOVE (which should not be called STORESCP :) and the one implementing the C-STORE behaviour. The answer I gave above, is aimed at the SCP implementing the C-STORE behaviour.
In university i'm doing EJB project on Java.
I have some Beans (Remote interface and it implementation, which do the main business logic). And i want to print some debugging text\information. For example:
#Stateless(mappedName = "BusinessLogicBean") // имя, по которому можно обращаться к этому бину извне)
public class BusinessLogicSessionBean implements BusinessLogicSessionBeanRemote, BusinessLogicSessionBeanLocal {
#PersistenceContext(unitName = "FoodDiary-ejbPU")
private EntityManager em;
#Override
public void addNewProduct(String name, Boolean isProducr, String kkal, String prot, String fat, String carb) {
System.out.printl("Now we are running method ADD NEW PRODUCT");
....
}
But when I use all methods - they are doing all business logic, but doesn't PRINT anywhere my phrase (which i'm writing with SOUT). I'm looked in Glassfish log, in log if executing my program - and there is nothing.
Could anyone tell - how can I print my information from Session Beans ?
Try to use debugger to make shure your System.out.println reached by app. Generally it looks ok.
According to glassfish documentation:
https://docs.oracle.com/cd/E19798-01/821-1752/beafc/index.html
Enabling Verbose Mode
To have the server logs and messages printed to System.out on your command prompt screen, you can start the server in verbose mode. This makes it easy to do simple debugging using print statements, without having to view the server.log file every time.
To start the server in verbose mode, use the ----verbose option as follows:
asadmin start-domain --verbose [domain-name]
When the server is in verbose mode, messages are logged to the console or terminal window in addition to the log file. In addition, pressing Ctrl-C stops the server and pressing Ctrl-\ (on UNIX platforms) or Ctrl-Break (on Windows platforms) prints a thread dump. On UNIX platforms, you can also print a thread dump using the jstack command (see http://java.sun.com/javase/6/docs/technotes/tools/share/jstack.html) or the command kill -QUIT process_id.
I have a JBOSS batch application that sometimes sends hundreds on emails in a minute to the same email address with Log4J errors. This causes problems with Gmail, because it says we are sending emails too quickly for that gmail account.
So I was wondering if there was a way to basically create a "digest" or "aggregate" email puts all the error logs in 1 email and sends that every 5 minutes. So that way every 5 minutes we may get a large email, but at least we actually get the email instead of it being delayed for hours and hours by gmail servers rejecting it.
I read this post that suggested something about using an evaluator to do that, but I couldn't see how that is configured in the Log4J xml configuration file. It also seemed like it might not be able to "digest" all the logs into 1 email anyway.
Has anyone done this before? Or know if it's possible?
From (the archived) SMTPAppender Usage page:
set this property
log4j.appender.myMail.evaluatorClass = com.mydomain.example.MyEvaluator
Now you have to create the evaluator class and implement the org.apache.log4j.spi.TriggeringEventEvaluator interface and place this class in a path where log4j can access it.
//Example TriggeringEventEvaluator impl
package com.mydomain.example;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.TriggeringEventEvaluator;
public class MyEvaluator implements TriggeringEventEvaluator {
public boolean isTriggeringEvent(LoggingEvent event) {
return true;
}
}
You have to write the evaluator logic within this method.
I created a free useable solution for log4j2 with an ExtendedSmtpAppender.
(If you still use log4j 1.x, simply replace your log4j-1.x.jar with log4j-1.2-api-2.x.jar - and log4j-core-2.x.jar + log4j-api-2.x.jar of course.)
You get it from Maven Central as de.it-tw:log4j2-extras (This requires Java 7+ and log4j 2.8+).
If you are restricted to Java 6 (and thus log4j 2.3) then use de.it-tw:log4j2-Java6-extras
Additionally, see the GitLab project: https://gitlab.com/thiesw/log4j2-extras (or https://gitlab.com/thiesw/log4j2-Java6-extras)
[OLD text:
If you use log4j2, see answer to other stack overflow issue: https://stackoverflow.com/a/34072704/5074004
Or directly go to my external but publically available solution presented in https://issues.apache.org/jira/browse/LOG4J2-1192
]