Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35300

Re: Not closing connections and statements

Path csiph.com!feeder.erje.net!2.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.java.programmer
Subject Re: Not closing connections and statements
Date Sat, 13 Aug 2016 12:19:41 +0200
Organization Decebal Computing
Lines 59
Message-ID <871t1tkm2q.fsf@Equus.decebal.nl> (permalink)
References <87shuakxjq.fsf@Equus.decebal.nl> <nol6er$gf5$1@dont-email.me> <87k2fllkjf.fsf@Equus.decebal.nl> <nomfpc$t30$1@gwaiyur.mb-net.net>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="18865"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KmDqdZ+WKJ642EDgRhWuxVva27osHebc="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
X-Homepage http://www.decebal.nl/
Cancel-Lock sha1:2ImhzqQSzGtx6ylm+dZojf3KQjA= sha1:ZUIZvwWRPUzM9/ZXlN3YkqmfvJg=
Xref csiph.com comp.lang.java.programmer:35300

Show key headers only | View raw


On Saturday 13 Aug 2016 08:47 CEST, Marcel Mueller wrote:

> On 12.08.16 23.55, Cecil Westerhof wrote:
>> That is what I use yes. I just write one record an hour to log the
>> memory usage of the application. But maybe I am going to log more
>> in the future.
>
> If it is just for logging with auto commit I would not care much.
> However, it might or might not be a good advice to intentionally
> keep a DB connection idle for an hour. I would prefer to close the
> connection after each log write. In this scenario your question is
> pointless.

I have thought about opening and closing every time, but for the
moment I decided against it.


> But as already mentioned, log4j might be a good advice. But from my
> experience any logging to a database is at most the second-best
> solution. In critical situations it might not be reliable enough and
> you loose exactly the log records that you really need. Of course,
> it depends on your use case. Logging only once an hour might not
> fall into this category.

At the moment it is just to have some easily accessible information
about the memory usage of the applications. I think it would be rare
to loose a record, but even when that happens that would not be very
big disaster.

I did work a little bit with log4j, but it never hurts to deepen my
knowledge of it.


>> It works great: it is much better to get you log information out of
>> a (SQLite) database as from different files.
>
> As soon as your program runs twice for some reason, you might think
> different. ;-)

That is why I also but the PID in the record. ;-)


> However, appending to the same file from different JVMs portably and
> atomically is also a challenge, albeit possible in Java.

I just used Bash redirection. And once it went wrong because I used
the same file.


> The library also handles switching the logs from time to time to
> limit their size as well as the cleanup of old logs. So no disk will
> get full after years, because no one cleaned up the logs. In

That is very easy to do with SQLite. ;-)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 13:59 +0200
  Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 09:15 -0400
    Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 09:39 -0400
    Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-12 22:31 +0200
      Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 22:04 -0400
        Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-13 07:55 +0200
  Re: Not closing connections and statements Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-12 19:01 +0000
    Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-12 22:35 +0200
      Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:52 -0400
    Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 23:55 +0200
      Re: Not closing connections and statements Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-12 18:16 -0400
        Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 01:19 +0200
          Re: Not closing connections and statements Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-13 00:21 +0000
            Re: Not closing connections and statements Gunter Herrmann <gunter.herrmann@earthlink.net> - 2016-08-17 16:38 -0400
      Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:58 -0400
        Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:50 +0200
      Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:59 -0400
      Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-13 08:47 +0200
        Re: Not closing connections and statements Andreas Leitgeb <avl@logic.at> - 2016-08-13 08:05 +0000
          Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:21 +0200
          Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 09:54 -0400
        Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:19 +0200
        Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 10:04 -0400
          log4j RollingFileAppender (was: Not closing connections and statements) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-14 22:24 +0200
            Re: log4j RollingFileAppender Arne Vajhøj <arne@vajhoej.dk> - 2016-08-14 21:01 -0400
        Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 11:58 -0400
          logging (was: Not closing connections and statements) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-14 23:46 +0200
    Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:44 -0400
  Re: Not closing connections and statements Florian Weimer <fw@deneb.enyo.de> - 2016-08-13 16:33 +0200
    Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 17:34 +0200

csiph-web