Logging stack traces

  • 3
  • Locked
If you're approaching something more or less seriously, you will eventually come to some form of logging. Don't hesitate. Let's implement the log method. The log method should display the name of the class and method in which it is called, as well as the passed message. For clarity, use a colon and space to separate the class name, method name, and message.
You can't complete this task, because you're not signed in.
Comments (8)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Andrew Evans
Level 17 , San Jose, Canada
16 February 2022, 03:45
Forgot a damn semicolon
Level 15 , Bogota, Colombia
25 October 2020, 16:35
I've seen reports on a few posts. I feel like I need to tell you guys that the last intelliJ update messed up something with the pluggin. When you try to run a task without verification it will try to compile the last task (in this case task 905) as if you had not done it (at least for me). I'm just venting the frustration of not being able to see what I am actually printing.
Alex Vypirailenko Java Developer at Toshiba Global Comme
25 October 2020, 17:33
You are probably running one of the previous tasks, that's all. If you're using Windows, when you have the right class open hit the Ctrl+Shift+F10 keyboard combo to run it.
Level 15 , Bogota, Colombia
25 October 2020, 22:13
I've been unable to run the Codegym tasks without verifying them in both my computers (one's windows and the other one runs on Linux) and any task I want to run does this: I'm already done with task 902, I'm trying to run task 905 but for some reason the jvm is trying to compile the file of task 902 as it was before I completed the task. If I want to test any code I need to run it on a completely different project, which at the end of the day is not that bad. Is just frustrating in scenarios like the one above, where you'd want to run the program and actually see the stack
Alex Vypirailenko Java Developer at Toshiba Global Comme
25 October 2020, 23:44
From your screenshot it looks like you need to complete task 902, as the methods are missing all of the return statements. If any of the task in the same project have errors in them IntelliJ IDEA will not let you check any of your desired code until you fix the errors. This is how compilation works within a project.
hao Java Developer
2 December 2022, 04:59
Devonte A
Level 18 , Rubery, United Kingdom
12 June 2020, 10:28
Use index 2 for classname to pass verification :).
sreedhar s
Level 9 , Wellington, New Zealand
22 January, 22:35
Requirement which is confusing is below, 2. The displayed message must contain the name of the class whose method called the log method. Why do we need index 2 itself for passing the verification? when index 1 also returns the exact class name, and all the requirements are met and template text as well matches with the final answer with index 1 as well
String className = Thread.currentThread().getStackTrace()[1].getClassName();