If you're working in an IT environment, you can write:
Ich werde versuchen die Daten während der Laufzeit aufzuzeichnen*.
or
Ich werde versuchen die Daten zur Laufzeit aufzuzeichnen.
*("aufzunehmen" would work, too)
Whereas "aufzeichnen/aufnehmen" is usually translated as "record" and "zur/während der Laufzeit" as "during runtime".
On a ...

I agree with Stephie's answer. However, there is a different non-technical use.
I'm going to give a presentation, but I don't need to prepare anything. I'll deal with questions on the fly.
That would be roughly translated to German like this:
Ich werde eine Präsentation halten, aber ich muss mich nicht vorbereiten. Fragen beantworte ich aus dem ...

In a technical context like your example on the fly is used in a sense of "without stopping (the machine / the current process / the data flow / ...)".
For these situations the German translation would be:
im laufenden Betrieb
(The other sense of "in a hurry" doesn't really fit your example - unless you want to say that you get the data real quick.)

Your first sentence is correct, except that you should go with sondern instead of aber. In the sense of rather (not ... but ...), you translate but as sondern.
This is also true for your second sentence. That sentence, however, additionally misses a comma. Always put a comma before sondern. And also before aber.
Es war notwendig, nicht die Flasche, ...

You should replace »aber« by »sondern«:
Es war notwendig nicht die Flasche zu entdecken, sondern den Kasten.
Also correct:
Es war notwendig nicht die Flasche, sondern den Kasten zu entdecken.
In english:
It was necessary not to discover the bottle, but the box.

Genauer (literally: "more precisely"1) is a comparative, so you always need something to compare it to or, as it's typically used, a fact that can be specified - either in the same sentence or somewhere in the context.
Taking this into account, your first example makes sense, detailing a specific place in Bavaria:
Ich lebe in Bayern, genauer gesagt in ...

This one may be ours. I don't have an earlier attestation that 1908, but in that year it made a list of traditional proverbs, so it must go back a ways from there.
If you go to the link, it's no. 177 on the list (transcribed from the Yiddish using the official phonetic Romanization):
mit eyn tokhes kon men nit tantsn af tsvey khasenes.

Dictionaries can't convey the nuances that are expressed with such formulas as "Aber ... doch sonst auch immer". And it is no use looking up the single words. A sentence type with "Aber ... doch sonst auch immer" simply expresses someone's astonishment that a person behaves in a way contrary to his/her usual behaviour.
It is a ready-made formula, and the ...

A: speaker
B: spoken to
sonst
Refers to all the other times the B has had a drink there and also hints at a contradiction between this time and the other times.
For a detailed look on "sonst" check out this article on my blog.
auch
It seems a bit weird because B seems to NOT drink coffee this time. So why use "auch". But the "auch" doesn't talk about ...