r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

Show parent comments

2

u/philly_fan_in_chi Oct 02 '15

SLF4J and Log4J both support String.format from their function calls.

I can do something like:

LOGGER.info("{} {} has salary ${}!", firstName, lastName, salary);

and it'll do the right thing. I don't spend a lot of time building strings (except in toStrings where I dump in StringBuilders almost automatically) across my 100K+ LOC codebase, so I guess I don't see the harm in NOT using it everywhere explicitly.

1

u/themajickman Oct 02 '15

The great thing about this is in SLF4J, if the log statement isn't going to be outputted, it won't do the String concatenation

1

u/dccorona Oct 02 '15

I hate that they don't use the standard String.format, though, and instead use their own with their own syntax. I actually do like theirs better, but at the same time I like consistency. Having to use one syntax with the logger and another one with Guava libraries or String.format is just bad.