Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
95ef979b
Commit
95ef979b
authored
Aug 13, 2020
by
John Jarvis
Committed by
Mayra Cabrera
Aug 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds an environment variable to disable unstructured logging
parent
b6327b58
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
2 deletions
+20
-2
changelogs/unreleased/jarv-env-for-disabling-unstructured-log.yml
...gs/unreleased/jarv-env-for-disabling-unstructured-log.yml
+5
-0
config/initializers/lograge.rb
config/initializers/lograge.rb
+1
-1
doc/administration/environment_variables.md
doc/administration/environment_variables.md
+1
-0
lib/gitlab/app_logger.rb
lib/gitlab/app_logger.rb
+5
-1
spec/lib/gitlab/app_logger_spec.rb
spec/lib/gitlab/app_logger_spec.rb
+8
-0
No files found.
changelogs/unreleased/jarv-env-for-disabling-unstructured-log.yml
0 → 100644
View file @
95ef979b
---
title
:
Adds an environment variable override to disable unstructured logs
merge_request
:
39109
author
:
type
:
other
config/initializers/lograge.rb
View file @
95ef979b
...
...
@@ -5,7 +5,7 @@ unless Gitlab::Runtime.sidekiq?
Rails
.
application
.
configure
do
config
.
lograge
.
enabled
=
true
# Store the lograge JSON files in a separate file
config
.
lograge
.
keep_original_rails_log
=
true
config
.
lograge
.
keep_original_rails_log
=
Gitlab
::
Utils
.
to_boolean
(
ENV
.
fetch
(
'UNSTRUCTURED_RAILS_LOG'
,
'true'
))
# Don't use the Logstash formatter since this requires logstash-event, an
# unmaintained gem that monkey patches `Time`
config
.
lograge
.
formatter
=
Lograge
::
Formatters
::
Json
.
new
...
...
doc/administration/environment_variables.md
View file @
95ef979b
...
...
@@ -33,6 +33,7 @@ Variable | Type | Description
`GITLAB_UNICORN_MEMORY_MIN`
| integer | The minimum memory threshold (in bytes) for the Unicorn worker killer
`GITLAB_UNICORN_MEMORY_MAX`
| integer | The maximum memory threshold (in bytes) for the Unicorn worker killer
`GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN`
| string | Sets the initial registration token used for GitLab Runners
`UNSTRUCTURED_RAILS_LOG`
| string | Enables the unstructured log in addition to JSON logs (defaults to
`true`
)
## Complete database variables
...
...
lib/gitlab/app_logger.rb
View file @
95ef979b
...
...
@@ -5,7 +5,11 @@ module Gitlab
LOGGERS
=
[
Gitlab
::
AppTextLogger
,
Gitlab
::
AppJsonLogger
].
freeze
def
self
.
loggers
LOGGERS
if
Gitlab
::
Utils
.
to_boolean
(
ENV
.
fetch
(
'UNSTRUCTURED_RAILS_LOG'
,
'true'
))
LOGGERS
else
[
Gitlab
::
AppJsonLogger
]
end
end
def
self
.
primary_logger
...
...
spec/lib/gitlab/app_logger_spec.rb
View file @
95ef979b
...
...
@@ -19,4 +19,12 @@ RSpec.describe Gitlab::AppLogger do
subject
.
info
(
'Hello World!'
)
end
it
'logs info to only the AppJsonLogger when unstructured logs are disabled'
do
stub_env
(
'UNSTRUCTURED_RAILS_LOG'
,
'false'
)
expect_any_instance_of
(
Gitlab
::
AppTextLogger
).
not_to
receive
(
:info
).
and_call_original
expect_any_instance_of
(
Gitlab
::
AppJsonLogger
).
to
receive
(
:info
).
and_call_original
subject
.
info
(
'Hello World!'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment