You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Lee Theobald (JIRA)" <ji...@apache.org> on 2014/04/29 12:51:17 UTC

[jira] [Created] (LOG4J2-621) Pattern To Drop First X Package Parts

Lee Theobald created LOG4J2-621:
-----------------------------------

             Summary: Pattern To Drop First X Package Parts
                 Key: LOG4J2-621
                 URL: https://issues.apache.org/jira/browse/LOG4J2-621
             Project: Log4j 2
          Issue Type: Wish
          Components: Layouts
    Affects Versions: 2.0-rc1
            Reporter: Lee Theobald
            Priority: Trivial


Currently you can have a pattern that will print out the last X parts of you package.  So if my package was `uk.co.ltheobald.foo.bar`, then using `%logger{2}` will print `foo.bar`.  But when I have a number of different package levels, this becomes less useful (in my opinion).

What I'd find more useful is the inverse where I can ditch the first X parts.  Something like `%logger{-3}` for example.  That way I'd end up with:

`uk.co.ltheobald.Main logging` as `Main`
`uk.co.ltheobald.foo.MyClass` logging as `foo.MyClass`
`uk.co.ltheobald.foo.bar.MyOtherClass` logging as `foo.bar.MyOtherClass`

Removing from the start of the logger name allows me to consistently trim off package names that I know are always the same.

I'll see if I can produce a code example for this if I get time but I wanted to log it in the meanwhile.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org