Logger.exiting() method doesn't log class/method names
I'm trying to setup logging in a ResourceAdapter running in
Appserver 8. For some reason, when the Logger.exiting() method
is called, the class and method names are not logged.
Any ideas why this is happening ?
Thanks, Alan
private static final String _CLASSNAME = "MyResourceAdapter";
private static final String _PACKAGE = "com.wombat.myRA";
protected static Logger mLogger = null;
private void Initialise () {
mLogger = Logger.getLogger(_PACKAGE);
try {
mLogger.setLevel(Level.FINEST);
} catch(Exception e ) {
e.printStackTrace();
mLogger.exiting(_CLASSNAME,"Initialise","OK");
mLogger.exiting(_CLASSNAME,"Initialise");
}The log output looks like this :
[#|2004-11-11T13:59:10.351+0000|FINER|sun-appserver-pe8.1|com.wombat.myRA|_ThreadID=10;|RETURN {0}|#]
[#|2004-11-11T13:59:10.351+0000|FINER|sun-appserver-pe8.1|com.wombat.myRA|_ThreadID=10;|RETURN|#]
Following up after further investigation.
It's not just .exiting() that is failing to log the class/method names.
All methods on Logger fail to log the supplied class/method names.
Even manually creating a LogRecord and explicitly calling setSourceClassName()
and setSourceMethodName() fails to log the names.
Presumably this is because the supplied names are being ignored.
Anyone have any idea why this would happen?/
Thanks, Alan
PS. All this refers to java.util.logging.Logger
Similar Messages
-
Logger doesn't log fine() messages
I setup the Logger like so
try {
FileHandler handler = new FileHandler("JEL.log");
handler.setFormatter(new SimpleFormatter());
gLogger = Logger.getLogger("com.sidkwakkel.jel");
gLogger.addHandler(handler);
// The logging level can be set from the application options file
if(mOptions.getProperty("Logger_level").equalsIgnoreCase("all")) {
gLogger.getHandlers()[0].setLevel(Level.ALL);
gLogger.setLevel(Level.ALL);
} else if(mOptions.getProperty("Logger_level").equalsIgnoreCase("debug")) {
gLogger.getHandlers()[0].setLevel(Level.INFO);
gLogger.setLevel(Level.INFO);
} else if(mOptions.getProperty("Logger_level").equalsIgnoreCase("warnings")) {
gLogger.getHandlers()[0].setLevel(Level.WARNING);
gLogger.setLevel(Level.WARNING);
} else if(mOptions.getProperty("Logger_level").equalsIgnoreCase("off")) {
gLogger.getHandlers()[0].setLevel(Level.OFF);
gLogger.setLevel(Level.OFF);
gLogger.info("test info");
gLogger.fine("test fine");
}catch(IOException e) {}If I set my option file to
Logger_level : allit still only captures messages that are made using info(). All of my messages that use fine() are ignored. Any ideas?Following up after further investigation.
It's not just .exiting() that is failing to log the class/method names.
All methods on Logger fail to log the supplied class/method names.
Even manually creating a LogRecord and explicitly calling setSourceClassName()
and setSourceMethodName() fails to log the names.
Presumably this is because the supplied names are being ignored.
Anyone have any idea why this would happen?/
Thanks, Alan
PS. All this refers to java.util.logging.Logger -
Code will not compile when changing method name in related class
Hello all! I'm wondering if anyone can help a second-time poster. I have a class called Transcription which holds the artist name and song title of a guitar transcription. Transcription has a method toString() which returns a String containing the artist name and title. I have a class GuitarMag which holds a vector of Transcription objects, and has a method WriteGuitarMag() which returns a String containing, among other things, the toString() method for each Transcription in the transcriptions vector. I wanted to change the method name in Transcription to writeTranscription() for consistency, but when I refer to that method in WriteGuitarMag(), GuitarMag gives an error to the effect that the writeTranscription() method does not exist.
This works fine:
//Transcription object
public String toString(){
return "" + artistName + "\t\t" + songName;
//GuitarMag object
public String WriteGuitarMag() {
StringBuffer tmp1 = new StringBuffer();
//find out how many components are in the vector
int transCount = this.transcriptions.size();
StringBuffer tmp = new StringBuffer("Name: " + this.getMagName() + "\n" +
"Cover: " + this.getCoverDesc() + "\n" +
"Date: " + this.getMagDate() + "\n" +
"Transcriptions:" + "\n");
for (int i = 0; i < transCount; i++) {
tmp1.append(this.transcriptions.elementAt(i).toString() + "\n");
tmp.append(tmp1);
return tmp.toString();
}But this does not:
//Transcription object
public String writeTranscription(){
return "" + artistName + "\t\t" + songName;
//GuitarMag object
public String WriteGuitarMag() {
StringBuffer tmp1 = new StringBuffer();
//find out how many components are in the vector
int transCount = this.transcriptions.size();
StringBuffer tmp = new StringBuffer("Name: " + this.getMagName() + "\n" +
"Cover: " + this.getCoverDesc() + "\n" +
"Date: " + this.getMagDate() + "\n" +
"Transcriptions:" + "\n");
for (int i = 0; i < transCount; i++) {
tmp1.append(this.transcriptions.elementAt(i).writeTranscription() + "\n");
tmp.append(tmp1);
return tmp.toString();
}Any thoughts or feelings about this?Thanks for your reply. Yes, I compiled the Transcription class first, and then the GuitarMag class, so it shouldn't have been a problem. In thinking about it more today, I'm wondering if I need to cast the vector component to a Transcription object first. Because all objects have the toString() method, it works without casting, but if I rename the method it doesn't?
-
How to convert a String variable as class name and method name?
i have two classes
class Student
public String insertStudent(String sname)
{ return("Student has been inserted "); }
class Teacher
public String execute(String methodName, String className)
{ //return statement of the method 'insertStudent' in the class 'Student'; }
}Now, i have a class with the main method. Here, i would like to call the method *'insertStudent'* of class *'Student'*
using the method *'execute'* of class *'Teacher',* passing the method-name and the class-name (viz. insertStudent, Student) as the
String parameter.
Can anyone please help me out. Thanks
regards,
chinglaiYou should have just added that as a comment on your [initial posting|http://forums.sun.com/thread.jspa?threadID=5334953] instead of starting a new thread.
Now, i have a class with the main method. Here, i would like to call the method 'insertStudent' of class 'Student'using the method 'execute' of class 'Teacher', passing the method-name and the class-name (viz. insertStudent, Student) as the
String parameter.
Why oh why? What do you want to achieve?
Let me tell you: there is a way to do what you try to do, but it's not recommended and should be used only very sparingly. Especially not in anything like your code, that resembles normal business logic (as opposed to an application framework such as Spring, for example).
Can you explain what exactly you want to do with that? Why should a Teacher be able to call any random method ony any other class. And what good would that do? -
How to get the method names in a class
hi friends,
Could any of you tell me the report or function module to display all the method names in a given class.
thanks in advance.
regards,
kumarHi Kumar ,
Open ur class in SE24 transaction ,there is a tab for methods ..
u'll get the list of methods form there ... n in source u'll get their operative details
Regards
Renu -
hey to all my java Pals =)
i am working on an application right now
and my exit method behaves strangly
when you go to File|Exit
it will say
"this will exit are you sure
if the user says yes it will exit the program but if he says no it wont
but when you close it from the X up the Corner of the screen
it will say
"this will exit are you sure
but regardless of what user chose Yes|NO it will exit
what am i doing wrong thanks
my code
//File | Exit action performed
public void jMenuFileExit_actionPerformed(ActionEvent e) {
int forExit;
forExit = JOptionPane.showConfirmDialog(null,"This will Exit..........!!!!"+"\n"+"Are you Sure?","Exit?",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
System.out.println(forExit);
if(forExit==0){
System.exit(0);
//and for overriding the (X) on corner
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
jMenuFileExit_actionPerformed(null);
}sorry for my spelling its 12 at night and i didnt spell check
Thanks in advancehere is the code
public Frame1() {
addWindowListener(new java.awt.event.WindowAdapter(){
public void windowClosing(java.awt.event.WindowEvent evt){
jMenuFileExit_actionPerformed(null);
});and the exit
public void jMenuFileExit_actionPerformed(ActionEvent e) {
int forExit;
forExit = JOptionPane.showConfirmDialog(null,"This will Exit..........!!!!"+"\n"+"Are you Sure?","Exit?",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
System.out.println(forExit);
if(forExit==0){
System.exit(0);
} -
How do I find class name I should import for java method name
If I have the class name I know how to look in java docs list for methods.
If I have a method name but don't know the class,
how do I find class name I should import to use the java method name?I'm not sure the other reply answered your question. If you truly don't know the class name, one approach would be a Google search. Another approach works if you have an IDE. Eclipse, for example, can find the class for you (assuming it's on your classpath) & automatically import it for you. Ctrl-Shift-O normally does the trick.
-
Thread safe logging class, using final and static
Hi,
I'm looking through a logging class (which writes entries to a text file and so on) written by someone else, and I'm trying to determine whether it's thread-safe...
Essentially the class looks like this:
public final class Logger {
private static FileOutputStream fout;
private static PrinterWriter pout;
private static final long MaxLength = 100000;
static {
/* basically checks size of logfile, if bigger than 100k, then copy it as bak, and start again */
public void write(String msg) {
/* write entry into log file */
public void writeWithTimeStamp(string msg) {
/* write entry with time stamp into log file */
Now, I could be wrong, but I don't think that the class is thread-safe is it? in order to be thread-safe, I would have to use synchronized before write() and writeWithTimeStamp(), right?
My confusion arises from the use of the keyword "final" at the top of the class. This class isn't being inherited (or rather, there's no reason for the class not to be inheritable)... so what is it's purpose, if there is one?!
And my other question concerns the static block. But I need to describe the current setup first: The Logger class is being use by a file server. File server basically sits there, accepts socket connections from the outside, and takes text files and output them into a local directory. When a new socket connection is created, a new thread is created. As it stands right now, each thread instantiates its own Logger object which seems weird! Bringing me to my question which was, if each thread instantiates its own Logger object, the static block is only ran ONCE, regardless of how many threads (and therefore Logger objects) are created, right??
And wouldn't it be a better idea to simply create only ONE Logger object and pass it by reference to all newly created threads as they are needed so that all threads access the same and only Logger object? (and therefore utilize sychronization)
Thanks!In JDK 1.4, there are already classes written that do all of that work. Check out the docs for the java.util.logging package. Specifically, check out FileHandler (which can rotate log files if they are greater than a specified size) and LogRecord (which is a standardized way to store logging entries). I believe the class is threadsafe, it doesn't say it isn't. Try it and see. If not, you can easily make a threadsafe wrapper for it (or any class for that matter).
The online documentation is at:
http://java.sun.com/j2se/1.4/docs/api/index.html
If you are curious, the simplest way to make any class threadsafe, if you don't want to or are not able to modify the class code itself is to define another class that calls methods of the original class, but that is synchronized.
Example:
// NonThreadSafe.java
public class NonThreadSafe {
public NonThreadSafe (String s) {
// Constructor
public void SomeMethod (int param) {
// Do some important stuff here...
public int AnotherMethod (boolean param) {
// Do some more important stuff here...
// ThreadSafeWrapper.java
public class ThreadSafeWrapper {
protected NonThreadSafe nts;
public ThreadSafeWrapper (String s) {
nts = new NonThreadSafe(s);
public synchronized void SomeMethod (int param) {
nts.SomeMethod(param);
public synchronized int AnotherMethod (boolean param) {
return nts.AnotherMethod(param);
public NonThreadSafe GetNonThreadSafe () {
return nts;
};Unfortunately, ThreadSafeWrapper isn't derived from NonThreadSafe, so you are somewhat limited in what you can do with it compared to what you could do with NonThreadSafe. AFAIK, you can't override unsynchronized methods with synchronized ones.
Another thing you could do is just write a method that writes to your logging class, and synchronize just that method. For example:
// ThreadSafeLogger.java
public class ThreadSafeLogger {
public static synchronized void LogMessage (MyLogger log, String msg) {
log.writeString(msg);
// In another thread, far, far away:
ThreadSafeLogger.LogMessage(theLog, "Blah");
...Hope that helps.
Jason Cipriani
[email protected]
[email protected] -
How to determine method name at runtime
hello,
i try to get method name at runtime..i have a logger and i need this info for logger
private void method(){
myLogger.debug( "exception in " + getExecutedMethod() ); /* output should be: exception in method */
}best regards
cembcem wrote:
what i needed was
[http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html|http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html]
regards
cemYou could also use AOP to add logging. But really, any sort of injected logging is going to be of limited value, since it's very generic and "this method was called with these parameters"-esque. Explicit logging is a lot more descriptive and useful, particularly to support staff who probably won't know what any particular method does -
hi
can anyone know how to get the name of method from its catch block.
For example
i have a class called Hello.java
and inside that a method called display();
and i have a written the code inside a try catch block.so when an exception occurs i want to create a log file
i got the class name using this.getClass().getSimpleName()
so is there any way to get the method name , where the catch is written. (here in example i should get it as "display")
plz help me
im in great need.
hope u understood my doubt.
rgdsUse a logging framework, and name the loggers well & use meaningful messages?
Or create a Throwable, [fill in|http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html#fillInStackTrace()] the stack trace, get the required StackTraceElement and [get the method|http://java.sun.com/javase/6/docs/api/java/lang/StackTraceElement.html#getMethodName()] from this. -
How to know method name dynamically with sender or EventArgs object
Hello All,
I am working in ASP.NET. I wanna log method name in log file whenever that method is executed. e.g.
protected void Page_Load(object sender, EventArgs e)
Trace.Log("Page_Load start");
Trace.Log("Page_Load end");
protected void Method2(object sender, EventArgs e)
Trace.Log("Method2 start");
Trace.Log("Method2 end");
Trace.Log() is use to log my string in log files at D:\. Now, here I have hard coded Method name in Trace.Log(). But, now I want to fetch method name via c# code. Can we achieve it via sender or EventArgs object?
Please assist.
Thanks, ChintanHello Chintan,
You can get class name through reflection as it gets STATIC info about the component.
However, to get the line number of an exception, which is a run time parameter, you cannot use reflection.
I actually have not tried this before but, given it did not work for you in the web part class, you may try the below code in your *.ascx.cs user control used by your visual web part.
//To Retrieve class name use this line:
string className = this.GetType().FullName;
// To retrieve other parameters including line number
try
TestFunction();
catch (Exception ex)
StackTrace st = new StackTrace(ex, true);
StackFrame[] frames = st.GetFrames();
// Iterate over the frames extracting the information you need
foreach (StackFrame frame in frames)
string stkFrame = string.Format("{0}:{1}({2},{3})", frame.GetFileName(), frame.GetMethod().Name, frame.GetFileLineNumber(), frame.GetFileColumnNumber());
For more info, please refer to this
post.
THosE wHo doN'T apPreCiATe LiFe, DOn't DeSerVe iT -
Re: Method name and/or line number available from withinForte?
To my knowledge there is no such capability with forte, and for sure it
would be nice. Short
of storing all that metadata at runtime, a compile-time substitution such
as is done with
most C preprocessors would work as well.
However, I believe the solution you've identified falls short in a deployed
fashion - I think
all that method name/line number stuff is only available from the workshop...
-J
At 02:54 PM 10/27/98 -0600, [email protected] wrote:
I'm sure this question has been asked many times, but I don't know that I've
ever heard the answer. Is there any way from Forte to access the method
name of the currently executing method? What about the current line number?
I'm sure you all know what I'm getting at by now -- when raising your own
custom exceptions or logging messages we'd like to be able to not hard-code
method names and line numbers into them. I know these are available with
log flags so this information is stored somewhere -- is there an API to
access it on an agent, the task, or the environment? The only way I can
think of doing this (which is not-so-elegant) is to force a Forte exception
to be raised (like access a method on a null TextData or something), then
immediately catch it and extract the method and line number from it. Is
there a more elegant way?
-J.C.
J.C. Hamlin, Senior Consultant, Forte National Practice
Born Information Services Group, Wayzata, MN
Ph: (612) 404-4000 Ph2: (612) 783-8270 FAX: (612) 404-4441
<[email protected]> <[email protected]>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>**************************************
John L. Jamison
Vice President and Chief Technology Officer
Sage IT Partners, Inc.
415 392 7243 x 306
[email protected]
The Leaders in Internet Enabled Business Change
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Method task.TraceBack () returns a string suitable for shoving on the error
stack, and representing a call trace. The method
method TomW_RaiseException.RaiseException
begin
ge : GenericException = New ();
ge.SetWithParams (SP_ER_USER, task.TraceBack ());
task.ErrorMgr.AddError (ge);
Raise ge;
end method;
produces the following when called from the display method of the window in
which it is embedded.
USER ERROR:
Traceback:
TomW_RaiseException.RaiseException at line 2
TomW_RaiseException.Display at line 4
TomW_RaiseException. at offset 13
C++ Method(s)
UserApp.Run at offset 96
Class: qqsp_Exception
Last TOOL statement: method TomW_RaiseException.RaiseException, line 3
Error Time: Wed Oct 28 08:28:34
Exception occurred (locally) on partition "TomW_Test_CL0_Client",
(partitionId = AA6475E0-3DD2-11D2-B582-04228BFFAA77:0x117f:0x6,
taskId =
[AA6475E0-3DD2-11D2-B582-04228BFFAA77:0x117f:0x6.34]) in application
"FTLaunch_cl0", pid 195 on node SPNMXSHOP7 in environment SFDEVL.
I suppose that a sufficiently determined person could parse the results of
TraceBack () and extract the
method and line from it. But I know of no method that explicitly returns
the name of the calling method.
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/> -
Hi all
I've got a error msg when try to generate a report using Cisco history report tool:
Error | An Exceptional Error occurred. Application exiting. Check the log file for error 5022
It only happens when choose report template: ICD_Contact_Service_Queue_Activity_by_CSQ_en_us.
User tried samething on other PC, it working fine.
only on user' own PC and only choose this report, error appears.
user runing windows 7 and do not have crystal report installed
tried reinstalled the software, doesn't work.
also tried this: (https://cisco-support.hosted.jivesoftware.com/thread/2041254) - doesn't work
then tried https://supportforums.cisco.com/docs/DOC-6209 - doesn't work
attached the log file.
thanks.wenqianyu wrote:From the log file:Looks like you get a Login Window.Error message showed up after username/password be enteredThere is an error in the log: Error happened in comparing UCCX version and HRC versionYou may need to do a clean uninstall, download the Historical report from the server, and install it again on the PC.Does this only happen to one PC or to every PC with this application?Wenqian
I have completely uninstalled the HRC, and download from server install again -- still doesn't work with exactly same error.
this matter only happens on this PC, when user try same thing on other PC, it works.
so i think it not relate to server or account. -
Using oc4j to generate interfaces from wsdl produced improper method names
The method names that were produced from the opperations in my WSDL, generated an interface file with incorrect method names. The name went from "DoTest" in the wsdl to "doTest" in the Interface file.
I double checked and all the cases are correct in the wsdl.
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by John Reynolds (MedPlus) -->
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:y="http://localhost/TestService" targetNamespace="http://localhost/TestService">
<types>
<xs:schema targetNamespace="http://localhost/TestService" xmlns="http://www.w3.org/2001/XMLSchema">
<xs:element name="Tresult" type="xs:string"/>
<xs:element name="Tname" type="xs:string"/>
<xs:element name="Tfault" type="xs:string"/>
</xs:schema>
</types>
<message name="DoTestResponse">
<part name="Result" element="y:Tresult"/>
</message>
<message name="DoTestRequest">
<part name="Name" element="y:Tname"/>
</message>
<message name="DoTestFault">
<part name="ExceptionDetail" element="y:Tfault"/>
</message>
<portType name="TestService">
<operation name="DoTest">
<input message="y:DoTestRequest"/>
<output message="y:DoTestResponse"/>
<fault name="DoTestException" message="y:DoTestFault"/>
</operation>
</portType>
<binding name="TestService" type="y:TestService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="DoTest">
<soap:operation soapAction="urn:#DoTest" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="DoTestException">
<soap:fault name="DoTestException" use="literal"/>
</fault>
</operation>
</binding>
<service name="TestServiceSoap">
<port name="TestService" binding="y:TestService">
<soap:address location="http://localhost/TestService"/>
</port>
</service>
</definitions>Obviously one could rename the operation to that standard, but that doesn't exactly strike me as being anything other that a work around for a bug.
WSDL provides a contract in which multiple languages have to conform to a set of interfaces, and it's not exactly good to have a tool, just a assume the contract for an interface is wrong.
I could argue that I'm only doing Java on the front end and .Net on the client side and that they don't neccessarily follow the Java convention, nor should be constrained by it.
I do agree with you that they probably just followed the convention when writing to code generator and just happened to pick up the convention. They just need to fix it now. -
Hi all,
In the names of some methods of a class I find IF....for example in the class CL_SMARTFORM_BCS there are methods like IF_DELETE_BCSDELETE , IF_COPY_BCSCOPY , IF_DOCUMENT_BCS~GET_BODY_PART_COUNT etc...At the same time there are methods like GET_SFPROCESS , CREATE.
Can anyone please tell me why is that the word IF..... is used before some methods? Is there any signifance with it?
Kindsly reply as fast as possible.
Regards,
VijayHi Bala..
These methods are actually defined in an Interface IF_DELETE_BCS.
A class can include an interface to Implement the methods.
In that case these methods are addressed like <interfaceName>~<method Name>.
Here ~ (Tilde) is the interface resolution operator. That indicates this method is actually defined in an interface. But you can call it like any other method in the Class.
<b>reward if Helpful</b>
Maybe you are looking for
-
Null Pointer Exception in Message Area
Hi! I just want to get some inputs. I have this Message Area to display errors in Web Dynpro, but from time to time I get this Null Pointer Exception when an event takes place. Don't know why this happens, but the trace is not found my code. Here's t
-
Wireless improved after safari update
Viewing web pages in the newest safari is a lot less sluggish (read: faster). The signal stays fixed at 5 bars. I haven't seen this stable wifi network behaviour in a long time. Could it be that wireless network troubles were partly caused by safari
-
My screen is not working. sometimes there is a shadow in the background
my screen is not allowing me to slide. i cant get to settings etc. sometimes there is a shadow in the background
-
Foreign vendor Excise registaration requirement at goods receipt of importP
Hi All, Let me know why does system ask to maintain excise registration data in J1ID transaction at the time of goods receipt. Although this foreighn vendor doesnot come under local jurisdiction. If required then what information need to be maintaine
-
Change keyboard shortcuts for zoom
Hi When looking at the keyboard shortcuts for MAC, the 100% zoom is down as command alt '0', yet it is showing in the dropdown list as 'n'? Is there a way of changing the shortcuts. Previously the 100% zoom was simply command (apple) '0', which is no