Skip to content

Commit 275626e

Browse files
authored
[DOCS] Add tab widget for default log locations (#64510) (#64588)
1 parent 835ebcf commit 275626e

File tree

4 files changed

+362
-0
lines changed

4 files changed

+362
-0
lines changed

docs/reference/setup/logging-config.asciidoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
[[logging]]
2+
=== Logging
3+
4+
include::{es-repo-dir}/tab-widgets/code.asciidoc[]
5+
6+
You can use {es}'s application logs to monitor your cluster and diagnose issues.
7+
If you run {es} as a service, the default location of the logs varies based on
8+
your platform and installation method:
9+
10+
include::{es-repo-dir}/tab-widgets/logging-widget.asciidoc[]
11+
12+
If you run {es} from the command line, {es} prints logs to the standard output
13+
(`stdout`).
14+
15+
[discrete]
16+
[[loggin-configuration]]
217
=== Logging configuration
318

419
Elasticsearch uses https://logging.apache.org/log4j/2.x/[Log4j 2] for
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
// Defining styles and script here for simplicity.
2+
++++
3+
<style>
4+
.tabs {
5+
width: 100%;
6+
}
7+
[role="tablist"] {
8+
margin: 0 0 -0.1em;
9+
overflow: visible;
10+
}
11+
[role="tab"] {
12+
position: relative;
13+
padding: 0.3em 0.5em 0.4em;
14+
border: 1px solid hsl(219, 1%, 72%);
15+
border-radius: 0.2em 0.2em 0 0;
16+
overflow: visible;
17+
font-family: inherit;
18+
font-size: inherit;
19+
background: hsl(220, 20%, 94%);
20+
}
21+
[role="tab"]:hover::before,
22+
[role="tab"]:focus::before,
23+
[role="tab"][aria-selected="true"]::before {
24+
position: absolute;
25+
bottom: 100%;
26+
right: -1px;
27+
left: -1px;
28+
border-radius: 0.2em 0.2em 0 0;
29+
border-top: 3px solid hsl(219, 1%, 72%);
30+
content: '';
31+
}
32+
[role="tab"][aria-selected="true"] {
33+
border-radius: 0;
34+
background: hsl(220, 43%, 99%);
35+
outline: 0;
36+
}
37+
[role="tab"][aria-selected="true"]:not(:focus):not(:hover)::before {
38+
border-top: 5px solid hsl(218, 96%, 48%);
39+
}
40+
[role="tab"][aria-selected="true"]::after {
41+
position: absolute;
42+
z-index: 3;
43+
bottom: -1px;
44+
right: 0;
45+
left: 0;
46+
height: 0.3em;
47+
background: hsl(220, 43%, 99%);
48+
box-shadow: none;
49+
content: '';
50+
}
51+
[role="tab"]:hover,
52+
[role="tab"]:focus,
53+
[role="tab"]:active {
54+
outline: 0;
55+
border-radius: 0;
56+
color: inherit;
57+
}
58+
[role="tab"]:hover::before,
59+
[role="tab"]:focus::before {
60+
border-color: hsl(218, 96%, 48%);
61+
}
62+
[role="tabpanel"] {
63+
position: relative;
64+
z-index: 2;
65+
padding: 1em;
66+
border: 1px solid hsl(219, 1%, 72%);
67+
border-radius: 0 0.2em 0.2em 0.2em;
68+
box-shadow: 0 0 0.2em hsl(219, 1%, 72%);
69+
background: hsl(220, 43%, 99%);
70+
margin-bottom: 1em;
71+
}
72+
[role="tabpanel"] p {
73+
margin: 0;
74+
}
75+
[role="tabpanel"] * + p {
76+
margin-top: 1em;
77+
}
78+
</style>
79+
<script>
80+
window.addEventListener("DOMContentLoaded", () => {
81+
const tabs = document.querySelectorAll('[role="tab"]');
82+
const tabList = document.querySelector('[role="tablist"]');
83+
// Add a click event handler to each tab
84+
tabs.forEach(tab => {
85+
tab.addEventListener("click", changeTabs);
86+
});
87+
// Enable arrow navigation between tabs in the tab list
88+
let tabFocus = 0;
89+
tabList.addEventListener("keydown", e => {
90+
// Move right
91+
if (e.keyCode === 39 || e.keyCode === 37) {
92+
tabs[tabFocus].setAttribute("tabindex", -1);
93+
if (e.keyCode === 39) {
94+
tabFocus++;
95+
// If we're at the end, go to the start
96+
if (tabFocus >= tabs.length) {
97+
tabFocus = 0;
98+
}
99+
// Move left
100+
} else if (e.keyCode === 37) {
101+
tabFocus--;
102+
// If we're at the start, move to the end
103+
if (tabFocus < 0) {
104+
tabFocus = tabs.length - 1;
105+
}
106+
}
107+
tabs[tabFocus].setAttribute("tabindex", 0);
108+
tabs[tabFocus].focus();
109+
}
110+
});
111+
});
112+
function setActiveTab(target) {
113+
const parent = target.parentNode;
114+
const grandparent = parent.parentNode;
115+
// console.log(grandparent);
116+
// Remove all current selected tabs
117+
parent
118+
.querySelectorAll('[aria-selected="true"]')
119+
.forEach(t => t.setAttribute("aria-selected", false));
120+
// Set this tab as selected
121+
target.setAttribute("aria-selected", true);
122+
// Hide all tab panels
123+
grandparent
124+
.querySelectorAll('[role="tabpanel"]')
125+
.forEach(p => p.setAttribute("hidden", true));
126+
// Show the selected panel
127+
grandparent.parentNode
128+
.querySelector(`#${target.getAttribute("aria-controls")}`)
129+
.removeAttribute("hidden");
130+
}
131+
function changeTabs(e) {
132+
// get the containing list of the tab that was just clicked
133+
const tabList = e.target.parentNode;
134+
135+
// get all of the sibling tabs
136+
const buttons = Array.apply(null, tabList.querySelectorAll('button'));
137+
138+
// loop over the siblings to discover which index thje clicked one was
139+
const { index } = buttons.reduce(({ found, index }, button) => {
140+
if (!found && buttons[index] === e.target) {
141+
return { found: true, index };
142+
} else if (!found) {
143+
return { found, index: index + 1 };
144+
} else {
145+
return { found, index };
146+
}
147+
}, { found: false, index: 0 });
148+
149+
// get the tab container
150+
const container = tabList.parentNode;
151+
// read the data-tab-group value from the container, e.g. "os"
152+
const { tabGroup } = container.dataset;
153+
// get a list of all the tab groups that match this value on the page
154+
const groups = document.querySelectorAll('[data-tab-group=' + tabGroup + ']');
155+
156+
// for each of the found tab groups, find the tab button at the previously discovered index and select it for each group
157+
groups.forEach((group) => {
158+
const target = group.querySelectorAll('button')[index];
159+
setActiveTab(target);
160+
});
161+
}
162+
</script>
163+
++++
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
++++
2+
<div class="tabs" data-tab-group="os">
3+
<div role="tablist" aria-label="logs">
4+
<button role="tab"
5+
aria-selected="true"
6+
aria-controls="docker-tab-logs"
7+
id="docker-logs">
8+
Docker
9+
</button>
10+
<button role="tab"
11+
aria-selected="false"
12+
aria-controls="deb-tab-logs"
13+
id="deb-logs">
14+
Debian (APT)
15+
</button>
16+
<button role="tab"
17+
aria-selected="false"
18+
aria-controls="rpm-tab-logs"
19+
id="rpm-logs"
20+
tabindex="-1">
21+
RPM
22+
</button>
23+
<button role="tab"
24+
aria-selected="false"
25+
aria-controls="mac-tab-logs"
26+
id="mac-logs"
27+
tabindex="-1">
28+
MacOS
29+
</button>
30+
<button role="tab"
31+
aria-selected="false"
32+
aria-controls="brew-tab-logs"
33+
id="brew-logs"
34+
tabindex="-1">
35+
Brew
36+
</button>
37+
<button role="tab"
38+
aria-selected="false"
39+
aria-controls="linux-tab-logs"
40+
id="linux-logs"
41+
tabindex="-1">
42+
Linux
43+
</button>
44+
<button role="tab"
45+
aria-selected="false"
46+
aria-controls="win-zip-tab-logs"
47+
id="win-zip-logs"
48+
tabindex="-1">
49+
Windows .zip
50+
</button>
51+
<button role="tab"
52+
aria-selected="false"
53+
aria-controls="win-msi-tab-logs"
54+
id="win--msilogs"
55+
tabindex="-1">
56+
Windows .msi
57+
</button>
58+
</div>
59+
<div tabindex="0"
60+
role="tabpanel"
61+
id="docker-tab-logs"
62+
aria-labelledby="docker-logs">
63+
++++
64+
65+
include::logging.asciidoc[tag=docker]
66+
67+
++++
68+
</div>
69+
<div tabindex="0"
70+
role="tabpanel"
71+
id="deb-tab-logs"
72+
aria-labelledby="deb-logs"
73+
hidden="">
74+
++++
75+
76+
include::logging.asciidoc[tag=deb]
77+
78+
++++
79+
</div>
80+
<div tabindex="0"
81+
role="tabpanel"
82+
id="rpm-tab-logs"
83+
aria-labelledby="rpm-logs"
84+
hidden="">
85+
++++
86+
87+
include::logging.asciidoc[tag=rpm]
88+
89+
++++
90+
</div>
91+
<div tabindex="0"
92+
role="tabpanel"
93+
id="mac-tab-logs"
94+
aria-labelledby="mac-logs"
95+
hidden="">
96+
++++
97+
98+
include::logging.asciidoc[tag=mac]
99+
100+
++++
101+
</div>
102+
<div tabindex="0"
103+
role="tabpanel"
104+
id="brew-tab-logs"
105+
aria-labelledby="brew-logs"
106+
hidden="">
107+
++++
108+
109+
include::logging.asciidoc[tag=brew]
110+
111+
++++
112+
</div>
113+
<div tabindex="0"
114+
role="tabpanel"
115+
id="linux-tab-logs"
116+
aria-labelledby="linux-logs"
117+
hidden="">
118+
++++
119+
120+
include::logging.asciidoc[tag=linux]
121+
122+
++++
123+
</div>
124+
<div tabindex="0"
125+
role="tabpanel"
126+
id="win-zip-tab-logs"
127+
aria-labelledby="win-zip-logs"
128+
hidden="">
129+
++++
130+
131+
include::logging.asciidoc[tag=win-zip]
132+
133+
++++
134+
</div>
135+
<div tabindex="0"
136+
role="tabpanel"
137+
id="win-msi-tab-logs"
138+
aria-labelledby="win-msi-logs"
139+
hidden="">
140+
++++
141+
142+
include::logging.asciidoc[tag=win-msi]
143+
144+
++++
145+
</div>
146+
</div>
147+
++++
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// tag::docker[]
2+
On <<docker,Docker>>, log messages go to the console and are handled by the
3+
configured Docker logging driver. To access logs, run `docker logs`.
4+
// end::docker[]
5+
6+
// tag::deb[]
7+
For <<deb,Debian installations>>, {es} writes logs to `/var/log/elasticsearch`.
8+
// end::deb[]
9+
10+
// tag::rpm[]
11+
For <<rpm,RPM installations>>, {es} writes logs to `/var/log/elasticsearch`.
12+
// end::rpm[]
13+
14+
// tag::mac[]
15+
For <<targz,MacOS `.tar.gz`>> installations, {es} writes logs to
16+
`$ES_HOME/logs`.
17+
// end::mac[]
18+
19+
// tag::brew[]
20+
For <<brew,MacOS Homebrew>> installations, {es} writes logs to
21+
`/usr/local/var/log/elasticsearch`.
22+
// end::brew[]
23+
24+
// tag::linux[]
25+
For <<targz,Linux `.tar.gz`>> installations, {es} writes logs to
26+
`$ES_HOME/logs`.
27+
// end::linux[]
28+
29+
// tag::win-zip[]
30+
For <<zip-windows,Windows `.zip`>> installations, {es} writes logs to
31+
`%ES_HOME%\logs`.
32+
// end::win-zip[]
33+
34+
// tag::win-msi[]
35+
For <<windows,Windows `.msi`>> installations, {es} writes logs to
36+
`%ALLUSERSPROFILE%\Elastic\Elasticsearch\logs`.
37+
// end::win-msi[]

0 commit comments

Comments
 (0)