···333333334334const parsedOptions: LogOptions = parseLogOptions(myConfig);
335335```
336336+337337+# Examples
338338+339339+Various use-cases for `@foxxmd/logging` and how to configure a logger for them.
340340+341341+Remember, `loggerApp` and `loggerAppRolling` **accept the same arguments.** The examples below use `loggerApp` but `loggerAppRolling` can be used as a drop-in replacement in order to use a rolling log file.
342342+343343+#### Log to Console and File
344344+345345+```ts
346346+import {loggerApp, loggerAppRolling} from '@foxxmd/logging';
347347+348348+// static log file at ./logs/app.log
349349+const staticLogger = loggerApp();
350350+351351+// rolling log file at ./logs/app.1.log
352352+const rollingLogger = loggerAppRolling();
353353+```
354354+355355+#### Log At Specific Level Or Higher for Console and File
356356+357357+```ts
358358+import {loggerApp} from '@foxxmd/logging';
359359+360360+// INFO is the default level
361361+// when 'console' is not specified it logs to 'info' or higher
362362+// when 'file' is not specified it logs to 'info' or higher
363363+const infoLogger = loggerApp();
364364+365365+// logs to console and log at 'debug' level and higher
366366+const debugLogger = loggerApp({level: 'debug'});
367367+```
368368+369369+#### Log At `debug` for Console and `warn` for File
370370+371371+```ts
372372+import {loggerApp} from '@foxxmd/logging';
373373+374374+const logger = loggerApp({
375375+ console: 'debug',
376376+ file: 'warn'
377377+});
378378+```
379379+380380+#### Do not log to File
381381+382382+```ts
383383+import {loggerApp} from '@foxxmd/logging';
384384+385385+// also logs to console at 'info' level
386386+const logger = loggerApp({
387387+ file: false
388388+});
389389+```
390390+391391+#### Log to Specific File
392392+393393+```ts
394394+import {loggerApp} from '@foxxmd/logging';
395395+396396+// also logs to console at 'info' level
397397+const logger = loggerApp({
398398+ file: {
399399+ path: './path/to/file.log'
400400+ }
401401+});
402402+```
403403+404404+#### Log to Rolling File with Unix Timestamp
405405+406406+```ts
407407+import {loggerApp} from '@foxxmd/logging';
408408+409409+// also logs to console at 'info' level
410410+const logger = loggerApp({
411411+ file: {
412412+ timestamp: 'unix'
413413+ }
414414+});
415415+```
416416+417417+#### Log to Rolling File with no timestamp
418418+419419+```ts
420420+import {loggerApp} from '@foxxmd/logging';
421421+422422+// also logs to console at 'info' level
423423+const logger = loggerApp({
424424+ file: {
425425+ // specify size but NOT 'frequency' to disable timestamps in filename
426426+ size: '10M'
427427+ }
428428+});
429429+```
430430+431431+#### Log to additional File for 'error' only
432432+433433+```ts
434434+import {loggerApp} from '@foxxmd/logging';
435435+import { buildDestinationFile } from "@foxxmd/logging/factory";
436436+437437+const errorFileDestination = buildDestinationFile('error', {path: './myLogs/warn.log'});
438438+439439+// also logs to console and file at 'info' level
440440+const logger = loggerApp({}, {
441441+ destinations: [errorFileDestination]
442442+});
443443+```
444444+445445+#### Log raw, newline-delimited json logs to additional File
446446+447447+```ts
448448+import {loggerApp} from '@foxxmd/logging';
449449+import { buildDestinationFile } from "@foxxmd/logging/factory";
450450+import fs from 'node:fs';
451451+452452+const rawFile = fs.createWriteStream('myRawFile.log');
453453+454454+// also logs to console and file at 'info' level
455455+const logger = loggerApp({}, {
456456+ destinations: [
457457+ {
458458+ level: 'debug',
459459+ stream: rawFile // logs are NOT prettified, only raw data from pino
460460+ }
461461+ ]
462462+});
463463+```
464464+465465+#### Log prettified data to additional stream
466466+467467+This could be used to trigger something when a log object with a specific property is found. Or to stream prettified log json to a client over websockets.
468468+469469+To emit data as an object ([`LogDataPretty`](https://foxxmd.github.io/logging/types/index.LogDataPretty.html)) set `objectMode` and `object` to true.
470470+471471+```ts
472472+import {loggerApp} from '@foxxmd/logging';
473473+import { buildDestinationJsonPrettyStream } from "@foxxmd/logging/factory";
474474+import { PassThrough } from "node:stream";
475475+476476+const prettyObjectStream = new Passthrough({objectMode: true}); // objectMode MUST be true to get objects from the stream
477477+const prettyObjectDestination = buildDestinationJsonPrettyStream('debug', {
478478+ destination: prettyObjectStream,
479479+ object: true, // must be set to true to use with objectMode stream
480480+ colorize: true
481481+});
482482+483483+const prettyStringStream = new Passthrough(); // will emit data as a json string
484484+const prettyStringDestination = buildDestinationJsonPrettyStream('debug', {
485485+ destination: prettyStringStream,
486486+ object: false,
487487+ colorize: true
488488+});
489489+490490+// also logs to console and file at 'info' level
491491+const logger = loggerApp({}, {
492492+ destinations: [
493493+ prettyObjectDestination,
494494+ prettyStringDestination
495495+ ]
496496+});
497497+498498+prettyObjectStream.on('data', (log) => {
499499+ // do something with log object (LogDataPretty)
500500+});
501501+502502+prettyStringStream.on('data', (log) => {
503503+ // do something with log string
504504+});
505505+```
506506+507507+#### Log to additional Pino Transports
508508+509509+Log to a [Pino Transport](https://getpino.io/#/docs/transports) like [pino-elasticsearch](https://getpino.io/#/docs/transports?id=pino-elasticsearch):
510510+511511+```ts
512512+import {loggerApp} from '@foxxmd/logging';
513513+import pinoElastic from 'pino-elasticsearch'
514514+515515+const streamToElastic = pinoElastic({
516516+ index: 'an-index',
517517+ node: 'http://localhost:9200',
518518+ esVersion: 7,
519519+ flushBytes: 1000
520520+});
521521+522522+// also logs to console and file at 'info' level
523523+const logger = loggerApp({}, {
524524+ destinations: [
525525+ {
526526+ level: 'debug',
527527+ stream: streamToElastic
528528+ }
529529+ ]
530530+});
531531+```