The main concern I have found with logging close to the source is that you are in danger of logging the same errors twice. In the second case we might imagine someone calling DoSomethingElse()
without being sure whether it would log the error. These cases become increasingly common as the size and complexity of the component increases, and the number of times an error is logged scales with size.
When errors are logged multiple times in multiple places, the density of useful information in the logs decreases and so the value of those logs also decreases.
When programmers instead follow the first example and log from a higher level there is much less danger of logs being repeated. Furthermore, at higher levels logs can include much more system meaning. DoSomethingElse()
may only be trying to send a SQL string to a Postgres database, while main
is trying to purge all expired user accounts.
The logs from DoSomethingElse
can only include very low level information -- the SQL query that was sent, the connection string tried, etc. -- while main
can provide all of these (because the error was transmitted upwards) but also provide a high level description, e.g. "Could not connect to the database while attempting to purge stale accounts.".
These high level descriptions make logs more valuable by providing useful glosses on the errors encountered. So in general I would recommend logging from the highest level possible.
The JSTL syntax required to make highly-interactive pages via JSP's is getting awfully unwieldy. I'm worried that, when we expand our project and bring on more engineers, there will be a steep-ish initial learning curve, followed by a persistent slow-down in the dev process due to verbosity of JSTL.
That is a legitimate concern.
Using JSP's also seems like a less contemporary approach to front-end dev, in light of how many JS frameworks are popular. I'm imagining it'd be tougher to field a team of front-end or full-stack engineers if we build with JSP's.
If you choose technologies that are suitable for your particular task in areas like ease of use, maintainability, sensible management of complexity, flexibility, and appropriateness for your application's specific functional and non-functional requirements, you will find people who know how to develop and maintain software using them.
Server-side rendering has been great for my testing, so far -- but what happens when our app is a massive, historic, global success and downright phenomenon?
If, and when, that happens, it will be a good problem, because then you'll have the money to fix it. Every large company has had to do this; they built their product on a platform that got them to market quickly, and re-built it (in some cases, from the ground-up) when the number of users became enormous.
That said, I think you can make some sensible choices early on. Unless your system requirements demand large, overblown architectures (they don't), avoiding them and choosing more nimble and flexible technologies will generally give you better overall performance and better adaptability.
Pushing view rendering duties onto client browsers seems like a cost-effective strategy for a cloud-hosted app such as ours. Am I mistaken in that thinking?
No. However, have a look at this Basecamp article.
Our app will be marketed to clients who are unfamiliar with technology. I think it's reasonable to assume that such clients will be disproportionately likely to have out-of-date browsers. Old browsers may have compatibility issues with JavaScript rendering -- and ever worse issues with the most modern JS frameworks.
There's just no excuse for this anymore. If your clients want to use computers in the 21st century, they need a modern browser, and it's easier than it's ever been to get one and allow it to maintain and update itself automatically and indefinitely.
After doing some research on these issues, I've got four strategies in mind...
The way of the future is so-called microservices and client-side UI such as Angular. And no, I don't think this just a fad. Users demand high interactivity with their software applications, and this arrangement can give it to them. Your back-end JSON web services can be built with anything you like; Node.JS, ASP.NET Web API, whatever. Maintaining this sort of modularity will make it possible to change out one component without affecting the others.
Best Answer
I don't think that article is implying that every method should should be logged that way, it's just saying when you're logging make sure you capture the context in which the log occurred.
For example, if you have a log which says only "User cannot be found", if you're actually trying to understand the scenario which lead to that log then you probably need to know the user ID at least. Typically function arguments have the most significant affect on the output of a function so that's the most important context to capture, but class or global variables might also be just as important depending on the situation.
In the case of a Spring web application, I definitely wouldn't be putting logging in every single function, but I would be logging where failures are likely. For example, if you make a call to an external service.
The article itself states:
Although, some of this logging might already be provided by your ORM or RDBMS so I wouldn't go adding logging to every single database call either.
The article also states:
Which typically aren't logged in production, so you might consider it an alternative to temporary print/echo statements during development. Again, only where appropriate.