I want to print in catch block directly with logger like:
Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);
I checked Velocity template in Settings - File and Code Templates for Catch Statement body
By Default it is given with
${EXCEPTION}.printStackTrace()
Tried changing with:
Logger.getLogger(${NAME}.class.getName()).log(LEVEL.INFO,${EXCEPTION}.printStackTrace(),${EXCEPTION});
but the Logger statement is getting wrong while, NAME is not picking class Name as provided in guidelines: https://www.jetbrains.com/help/idea/file-template-variables.html
Want to automatically put logger statement in catch block whenever I am using try-catch block or try with resources block to catch such that it has like:
Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);
It is not possible to use ${NAME} variable in
Code Templates
yet. You may try to use the following construction to get the class name:There is a similar request on JetBrains issues tracker: IDEA-55300