I want to create a new level(like INFO,ERROR) to use in xpertivy

asked 24.01.2014 at 08:07

toantp's gravatar image

toantp
(suspended)
accept rate: 0%

edited 18.02.2014 at 16:42

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)

Hi toantp This forum is for Xpert.ivy relevant questions only. Other questions will be delete in future. If you have very specific vietnam development questions that are not interessted for other users you can ask us directly via mail. Regards Reto Weiss, ivyTeam

(24.01.2014 at 17:34) Reto Weiss ♦♦ Reto%20Weiss's gravatar image

Hi toantp

To add your own level try this:

  1. use the following code to create an own level.
  2. set the Priority value in the log4j.xml to your level name (here: "TEST")
  3. Use your new level: logger.log(TestLevel.Test, "Test output");
  4. If the entry does not show up in the log, alter the DEBUGINT between -100 and + 100

    import org.apache.log4j.Level;
    
    public class TestLevel extends Level {
    
     public static final int TEST_INT = DEBUG_INT + 1;
    
     public static final Level TEST = new TestLevel(TEST_INT, "TEST", 7);
    
     protected TestLevel(int arg0, String arg1, int arg2) {  
         super(arg0, arg1, arg2);
    
     }
    
     public static Level toLevel(String sArg) {  
         if (sArg != null && sArg.toUpperCase().equals("TEST")) {  
             return TEST;  
         }  
         return (Level) toLevel(sArg, Level.DEBUG);  
     }
    
     public static Level toLevel(int val) {  
         if (val == TEST_INT) {  
             return TEST;  
         }  
         return (Level) toLevel(val, Level.DEBUG);  
     }
    
     public static Level toLevel(int val, Level defaultLevel) {  
         if (val == TEST_INT) {  
             return TEST;  
         }  
         return Level.toLevel(val,defaultLevel);  
     }
    
    public static Level toLevel(String sArg, Level defaultLevel) {       
        if(sArg != null && sArg.toUpperCase().equals("TEST")) {  
            return TEST;  
        }  
        return Level.toLevel(sArg,defaultLevel);  
        }  
     }
    
link

answered 11.02.2014 at 16:55

Daniel%20Oechslin's gravatar image

Daniel Oechslin
(suspended)
accept rate: 39%

edited 11.02.2014 at 16:58

Xpert.ivy uses the standard logging library Log4J from Apache. For more information see the Log4J web page.

link

answered 24.01.2014 at 17:29

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×28

Asked: 24.01.2014 at 08:07

Seen: 4,875 times

Last updated: 18.02.2014 at 16:42