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
cem

bcem 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

Similar Messages

  • How to get event name in runtime in the method ?

    i  found that there is a &_WORKITEM.OBJECTTYPE.EVENTS.NAME& element in thw workflow contained. then i do a binding from this element to another element with the same type as &_WORKITEM.OBJECTTYPE.EVENTS.NAME&.
       then in the method i use swc_get_element container 'NAME'  name.
      to get the event name in runtime.
      but when i test it in SWUE, it gives error.  If i remove this statement, it is oK
    ANY advice?

    Hello Gang,
    _WORKITEM is a workitem object
    OBJECTTYPE is its type (WORKINGWI for dialog steps)
    EVENTS is a multiline attribute (all events for this type of object: processed, created and deleted in our case /events of WORKINGWI/)
    I don't think that is what you need.
    You got an error, cause you link a multiline element to a single one.
    If you need an access to the TRIGGERING event name, the best is to bind an event name when it is triggered (or e.g. check an event name in the check FM if it is sufficient for your requirement).
    Regards,
    Michal

  • How to determine domain name in db_link?

    Hi all,
    when executing:
    create database link TST connect to myuser identified by pippo using 'MYTNS';I obtain the db link name with a suffixed domain, for example:
    TST.DOMAIN.COM
    Where does that domain come out from?
    How to determine it before db link creation?
    thanks a lot
    aldo

    solution found in thread
    REGRESS.RDBMS.DEV.US.ORACLE.COM  concates to every databaselink name.

  • 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, Chintan

    Hello 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

  • How to determine triggering event at runtime

    Hello,
    I was wondering how it is possible to determine which event was triggered to initiate a workflow.  I have a basic workflow that may be started via several events and would like to be able to determine within a method which event was the actual trigger.
    The key is to make this determination within the first standard task that is called after the event is triggered.  I thought I would be able to make this work by reading SWWLOGHIST using the top level WI_ID and method 'SWW_WI_CREATE_VIA_EVENT_INTERN' (event name is in PARA_VAL2 field).  This approach does not seem to work however and was wondering what the syntax would be to provide this value.
    Thanks in advance,
    Adam

    Hi,
    In the workflow header in the Version Independent(task) -> Start Event tab, Add the follwowing Binding
    &_EVT_NAME&  -> &eventname&
    (Where eventname is a container with HRS1212-EVENT type)
    You can use this as an import parameter in your method and utilize it.
    Regards
    Gautam

  • How to determine the name or type of a control in a existed VI?

    I got a couple of VIs other engineers created before. There are a couple of controls I can not tell the type or name of that control.
    I used LabVIEW ctrl-H to try to figure out what control was used but failed. I also tried to use "Edit\Customize Control" to determine that control, still could not find it.
    Please advise how can I figure out what kind of controls were used in some existed VI. Thanks,
    RY

    The name of the control is its label. It may have an empty label, meaning no name. It's also possible its label is invisible. Right click it and go to Visible Items to find out.
    As for the type, the color and shape of the icon is usually the best way to tell.
    Right click the diagram terminal of the control and select View as Icon. This might help you. If it doesn't, I suggest you post the 2 controls in an empty VI, and I'm sure someone can figure it out.
    Try to take over the world!

  • "Who ran me" - how to determine the name of the dbms_scheduler job that ran me

    Hi Community
    I can see plenty of examples out on the interweb which shows how you can use dbms_utility.format_call_stack to find the hierarchy of procs, functions and packages that got me to a particular point in my code.
    For example, if proc (procedure) A calls proc B, which in turn calls proc C, in the code for proc C, I can query the call stack to find out that proc C was called by proc B which in turn was called by proc A
    However, I want to extend this further.
    For example, using the example above, if proc A in turn was started by a dbms_scheduler job, I want to determine (within proc C) the name of the dbms_scheduler job which started the whole process off.
    The reason I want to do this is that I have inherited a (massive) system which is undocumented. In many places within the code, email alerts are sent out using a custom "MAIL" package to designated users (now including me) when certain long-running processes reach certain milestones and/or complete.
    I have added to the custom "MAIL" package a trailer on the mails to show the call stack. I also want to show the name of the dbms_scheduler job which started it all.
    Over time, this info may help me in building the "map" of how the whole undocumented system hangs together and in the meantime, to assist in troubleshooting problems
    Looking forward to hearing from you
    Alan

    Use USER_SCHEDULER_RUNNING_JOBS or DBA_SCHEDULER_RUNNING_JOBS there is column SESSION_ID and when you know your session ID build query is very simple.
    select owner, job_name
    into ...
    from dba_scheduler_runnig_jobs
    where session_id=sys_context('USERENV','SESSIONID');
    You must declare local variables in PL/SQL procedure to read owner and job_name into them. Second thing, you must handle possible exception no_data_found than can be raised when procedure is not run from job.

  • How to determine database name I am connected to ?

    I would like as simply and fast as possible to determine the database name, which I am currently connected to. Maybe the property jbo.sql92.JdbcDriverClass would do, but how to get its value ? Thanks for any suggestions.

    Ricky,
    don't understand that, why you don't use the session, when you are in BC4J (AM.getSession()) - which will give you at least the URL you connect too (in case you use a datasource - bad luck, as it is defined within the container ..)
    thx clemens

  • How to pass method name

    Could anyone please help. I want to pass a method's name to someother method, how can i pass the name of the method.
    say, I am in method1() and i want to pass its name that is method1 to another method method2(String str) , str would be method1's name. How can I do this.

    Could anyone please help. I want to pass a method's
    name to someother method, how can i pass the name of
    the method.
    say, I am in method1() and i want to pass its name
    that is method1 to another method method2(String str)
    , str would be method1's name. How can I do this.you would say method2("method1");

  • How to determine allowed names?

    Using Labview and an IVI-COM driver to talk to an oscilloscope. How can I determine the allowed names that I can use?

    You should have received this information from the vendor that sold you the IVI-COM driver.
    You might also consider using a native LabVIEW driver for your scope. If NI has one, I think it will be easier to use. Look at ni.com/idnet to see the available drivers.
    Brian

  • How to determine WD application at runtime?

    Hello,
    I have a WD compent which contains two WD applications.
    At runtime I want to control the layout by the WD aplication which was called. How can I do this?
    Thanks for you help,
    Thomas

    Hello Thomas,
    from the IF_WD_RR_APPLICATION you can get the current application name.
      data lo_comp_api type ref to if_wd_component.
      data lo_app type ref to if_wd_application.
      data lo_app_rr type ref to if_wd_rr_application.
      data lv_app_name type string.
      lo_comp_api = wd_comp_controller->wd_get_api( ).
      lo_app = lo_comp_api->get_application( ).
      lo_app_rr = lo_app->get_application_info( ).
      lv_app_name = lo_app_rr->get_name( ).
    BR, Saravanan

  • File to idoc how to get file name at runtime

    Hi Experts,
    In my file to idoc scenario,
    the requiremnt is like in mapping i have to give condition like if file name is name1 then one target filed is 40 and if file name is name2 then that target field is 60.
    how can we achieve this ?
    Regards,
    rohit

    Hi Rohit
    mughdha is right but you can do it through graphical mapping easily
    give condition in fix value under category conversion like this
    1) source-> FIX VALUE ->if value is true then map FIX value
    else nothing
    double click on first FIX VALUE function and assign your input values for file (for ex 40 or 60,......) in the key field and in the value field assign TRUE
    if this condition will be true the it willl map second FIX VALUE
    else assign a constant with empty value
    in second fix value assign values (for ex 40 or 60,......) which you have checked in first FIX VALUE function in key field and assign corresponding name which you required in the value field
    hope this will solve your problem
    Thanks
    sandeep
    if helpful reward points

  • How to determine InfoCube name within the update rule start routine?

    We are attempting to delete all the records where all key figure values are zeroes. We have about 15% of such records and we really don't need them.
    We have yearly InfoCubes. We copy the InfoCube and update rules at the end of every year. So, we don't want to hard code any field names within the update rules.
    If I could determine the target InfoCube name within the update rule start routine, I can find out all the key figures dynamically. But, I don't see a way of finding out the InfoCube name.
    If you would share any ideas, I would really appreciate.
    Thanks.
    Sudhi Karkada.

    Hi Sudhi,
    I dont know if this is what you are looking for.
    if you want to delete a record from being inserted when all the Key figure values are ZERO then you can use a Update Routine for some characteristic in the below way
    If looking for the InfoCube:
    if COMM_STRUCTURE-KF1 = 0 and COMM_STRUCTURE-KF2 AND....
      RETURNCODE = 4.
    else
      RESULT = COMM_STRUCTURE-ChanracteristicObject.
    endif.
    If it is to an ODS / InfoCube in the start routine.
      DELETE DATAPACKAGE where KF1=0 and kf2=0 and .....
    Hope it helps.
    Regards,
    Praveen.
    ENDLOOP.
    Message was edited by: Praveen

  • How to determine program name in static main

    What code can I execute in static main to get the name of the class provided as an argument to the java interpreter on the command line (since args doesn't include it)?
    Or is this simply not possible in Java?
    Why do I need this? I'm subclassing the class that defines static main, using the subclass as the program class, and want to instantiate it reflectively in main. Currently, I'm passing in the subclass name as an argument, so it appears on the command line twice, which seems awfully silly.

    JoachimSauer wrote:
    shdanfo wrote:
    The question is very simple: In Java, is it possible to execute code in static main that returns the name of the program class provided to the java interpreter?Let me get that straight.
    You have something similar to this:
    public class Foo {
    public static void main(String[] args) {
    String programName = ...;
    System.out.println(programName);
    }And you want to know what your have to replace "..." with so that the program outputs "Foo". Is that correct?
    I'd suggest either Foo.class.getName() or even simpler "Foo".I don't know if I'm getting this wrong now or not. It also sounds like the OP wants to know the name so that he can use reflection to create an instance. But all of that code could in that case be replaced with:
    public class Foo {
        public static void main(String[] args) {
            Foo foo = new Foo();
    }    Since he knows that this implementation of main is located in the class Foo.
    Kaj

  • How to determine method signature

    Consider the following compilation unit in Java where ecran.afficher essentially is System.out.println. I do not understand why no error is detected at compile-time. According to me, at least the call d.m(d,c) is incorrect. There is an ambiguity between methods A.m(D, A) and D.m(A, A). But the compiler choses A.m(D, A). I cannot figure out why.
    class A
    void m(A x, A y){ ecran.afficher("A.m(A, A) -- stop") ; }
    void m(D x, A y){ ecran.afficher("A.m(D, A)") ; m(y, x) ; }
    class B extends A
              void m(A x, A y){ ecran.afficher("B.m(A, A)") ; y.m(x, x) ; }
              void m(B x, A y){ ecran.afficher("B.m(B, A)") ; y.m(x, x) ; }
              void m(A x, C y){ ecran.afficher("B.m(A, C)") ; y.m(x, x) ; }
    class C extends B
    void m(A x, A y){ ecran.afficher("C.m(A, A)") ; x.m(y, this) ; }
              void m(B x, A y){ ecran.afficher("C.m(B, A)") ; x.m(y, this) ; }
              void m(A x, C y){ ecran.afficher("C.m(A, C)") ; x.m(y, this) ; }
    class D extends A
    void m(A x, A y){ ecran.afficher("D.m(A, A) -- stop") ; }
    class Q3
    public static void main(String[] args){
    A a = new A() ; B b = new B() ; C c = new C() ; D d = new D() ;
              A w = d ; A x = b ; B y = c ; A z = c ;
              d.m(d, c) ;
              d.m(x, y) ;
              z.m(a, b) ;
              c.m(d, x) ;
              y.m(z, a) ;
    }

    Thanks for giving me the pointer to the Specification
    (third edition). Thus as far as I can
    understand it, something fundamental has changed from
    the second to the third edition. Now the class where
    the method is declared is no longer taken into
    account.
    I suppose that this change is considered acceptable
    by the Java designers since it increases the number
    of accepted programs. My program is rejected by the
    first two versions of the specification, not by the
    third one.
    I really feel it a bad idea to change such
    fundamental aspects.I disagree.
    As far as I can tell, the way the 2nd ed. is worded is a bug. I believe that the behavior you observe is what was intended all along, but that strict adherence to JLS 2nd ed. would lead to a compile time error due to ambiguity. A cannot be converted to D by method invocation conversion, so neither method matches both of the conditions.
    I could be missing something though.
    When the JLS has bugs--following it strictly leads to behavior that differs from the authors' intent--inconsistencies, or ambiguities, it must be revised. Naturally, the addition of new language features also requires revision of the spec.
    At the same times, Java becomes so complex that I
    really doubt that somebody is still able to write
    correct programs in Java (i.e., a priori, not by
    trial and error).I don't consider that a problem. Except for minimal, toy programs, I've never written a program that was perfect the first time. Nor do I need to. The compiler finds certain kinds of errors much more quickly and accurately than I ever could, and unit testing takes care of most of the rest.
    Now, if you mean that nobody is able to write reasonably bug-free code with a reasonable amount of time and effort, I disagree. But that's entirely subjective anyway.
    When I started to teach Java, I spent many days
    reading the specification (first edition) carefully.
    A few years later, I bought the second edition. But I
    found the changes so complex (the new author is
    credited as a "programming language theologist" !)
    that I almost immediately decided to stick to the
    first edition for ever.Then you have to live with the bugs and shortcomings of that editon. You also have to stick with using the corresponding version of the compiler (1.1 or whatever), or have a lang spec. that doesn't match the compiler that implements it.
    Now, looking at the cryptic description of the third
    edition, I just can say : "The world is getting
    crazy". Who could possibly understand and use that ?I don't see the problem. It took me about ten minutes of fairly intesnse concentration to understand the relevant bits. It's not Dr. Seuss, but then, it's not intended to be. A general purpose computer language that has the kinds of features Java does is inherently complex. It requires a complex spec to define it precisely and accurately.
    The problem is that I am teaching Java as a first
    programming language in my University.That's reasonable. However, I don't think that Java's goals ever included being simple enough and unchanging enough to be easily grasped in its entirety by entry level university students.
    I have to say
    to my students : This language is changing all the
    time. Yes. As are huge tracts of the technology landscape. It's the nature of the beast.
    Also my demonstration programs are behaving
    differently each year ! That sounds odd. Most of Java's changes as it moves forward have allowed programs written with earlier versions to compile and run unchanged with newer versions.
    And I am forced to use the
    latest version of the JDK, always bigger and bigger.Forced by whom? By you school's policy?
    And I hate it !At the risk of sounding condescending, if you are that resistant to change, computer science may not be the ideal field for you.
    Now what shall I do ? Since I will refuse trying to
    read and understand the third editionNow it sounds like you're pouting. "My job is too hard. I won't do it. I won't I won't I won't."
    (and the
    fourth, the fifth...), I will probably teach an
    hypothetical Java, invented by myself, and "directly
    understandable". ("Tout ce qui n'est pas direct est
    nul." (E.M. Cioran))That's your choice, I guess, but if you don't inform your students very clearly and emphatically that said language is something idealized for your convenience and doesn't reflect the real world, then you'll be doing them a great disservice (and possibly be violating Sun's license agreements or trademarks).

Maybe you are looking for