Last active
December 7, 2022 12:56
-
-
Save udaybhaskar-v/00095d93692ed1ac9b6f75ceaed53701 to your computer and use it in GitHub Desktop.
Autogenerate logger statements using live templates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<templateSet group="Log4j"> | |
<template name="log4j" value="private final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(getClass());" description="log4j declaration" toReformat="true" toShortenFQNames="true"> | |
<context> | |
<option name="JAVA_DECLARATION" value="true" /> | |
</context> | |
</template> | |
<template name="log4d" value="$LOGGER_VAR$.debug("$EXPR_COPY$ = " + $EXPR$);" description="log4j debug statement" toReformat="true" toShortenFQNames="true"> | |
<variable name="LOGGER_VAR" expression="variableOfType("org.apache.log4j.Logger")" defaultValue="" alwaysStopAt="false" /> | |
<variable name="EXPR_COPY" expression="escapeString(EXPR)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="EXPR" expression="variableOfType("")" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_STATEMENT" value="true" /> | |
</context> | |
</template> | |
<template name="log4i" value="$LOGGER_VAR$.info("$EXPR_COPY$ = " + $EXPR$);" description="log4j Info statement" toReformat="true" toShortenFQNames="true"> | |
<variable name="LOGGER_VAR" expression="variableOfType("org.apache.log4j.Logger")" defaultValue="" alwaysStopAt="false" /> | |
<variable name="EXPR_COPY" expression="escapeString(EXPR)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="EXPR" expression="variableOfType("")" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_STATEMENT" value="true" /> | |
</context> | |
</template> | |
<template name="log4e" value="$LOGGER_VAR$.error("$EXPR_COPY$ = ", $EXPR$);" description="log4j error statement" toReformat="false" toShortenFQNames="true"> | |
<variable name="LOGGER_VAR" expression="variableOfType("org.apache.log4j.Logger")" defaultValue="" alwaysStopAt="false" /> | |
<variable name="EXPR_COPY" expression="escapeString(EXPR)" defaultValue="" alwaysStopAt="false" /> | |
<variable name="EXPR" expression="variableOfType("java.lang.Exception")" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="COMPLETION" value="true" /> | |
<option name="JAVA_STATEMENT" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
create log4j.xml File and paste it in /.IntelliJIdea2017.2/config/templates folder.
Shortcuts for templates
log4j --> Logger variable declaration
log4d --> Logger debug statement
log4i --> Logger info statement
log4e --> Logger error statement