Fetching logs from log file using grepHow to match multiple lines starting with a TAB, and the line before...
Was touching your nose a greeting in second millenium Mesopotamia?
Fedora boot screen shows both Fedora logo and Lenovo logo. Why and How?
What does "THREE ALPHA in Virginia" mean?
How many codes are possible?
What determines the "strength of impact" of a falling object on the ground, momentum or energy?
Why is C++ initial allocation so much larger than C's?
Layout of complex table
Is this one of the engines from the 9/11 aircraft?
Why isn’t the tax system continuous rather than bracketed?
The use of "I" and "we" used in the same sentence and other questions
Short story with brother-sister conjoined twins as protagonists?
What does 2>&1 | tee mean?
How many satellites can stay in a Lagrange point?
Plata or Dinero
Why is Madam Hooch not a professor?
Should I tell my insurance company I'm making payments on my new car?
Find smallest index that is identical to the value in an array
How risky is real estate?
What is this particular type of chord progression, common in classical music, called?
What is the line crossing the Pacific Ocean that is shown on maps?
Should I include salary information on my CV?
Alphabet completion rate
How to determine what is the correct level of detail when modelling?
Bash echo $-1 prints hb1. Why?
Fetching logs from log file using grep
How to match multiple lines starting with a TAB, and the line before the 1st one in a group?Return line conditonally on next lineHow to write and handle custom log file properly?GREP uppercase characters from a specific column, pipe the result to same file as new columnTail Grep - Print surrounding lines until pattern is matchedGetting a range of lines between timestamps from /var/log/messagesHow to remove a group of lines from a file?Grep file contents EXCEPT match case WITH contextgrep or awk to extact xml from log based on search stringgrep everything up until and including a pattern
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am trying to fetch logs from log file using grep
command and format of log file is as follows:
[1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
at com.own.ws.wim.util.UniqueNameHelper.formatUniqueName(UniqueNameHelper.java:102)
at com.own.ws.wim.ProfileManager.getImpl(ProfileManager.java:1569)
Until now, I am able to fetch logs but I want stack trace as well.
grep -i '^[[:space:]]*at' --before-context=2 SystemOut.log | grep "1/13/16 7:[1-60]"
output : [1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
Any idea how this can be achieved?
grep logs
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I am trying to fetch logs from log file using grep
command and format of log file is as follows:
[1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
at com.own.ws.wim.util.UniqueNameHelper.formatUniqueName(UniqueNameHelper.java:102)
at com.own.ws.wim.ProfileManager.getImpl(ProfileManager.java:1569)
Until now, I am able to fetch logs but I want stack trace as well.
grep -i '^[[:space:]]*at' --before-context=2 SystemOut.log | grep "1/13/16 7:[1-60]"
output : [1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
Any idea how this can be achieved?
grep logs
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I am trying to fetch logs from log file using grep
command and format of log file is as follows:
[1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
at com.own.ws.wim.util.UniqueNameHelper.formatUniqueName(UniqueNameHelper.java:102)
at com.own.ws.wim.ProfileManager.getImpl(ProfileManager.java:1569)
Until now, I am able to fetch logs but I want stack trace as well.
grep -i '^[[:space:]]*at' --before-context=2 SystemOut.log | grep "1/13/16 7:[1-60]"
output : [1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
Any idea how this can be achieved?
grep logs
I am trying to fetch logs from log file using grep
command and format of log file is as follows:
[1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
at com.own.ws.wim.util.UniqueNameHelper.formatUniqueName(UniqueNameHelper.java:102)
at com.own.ws.wim.ProfileManager.getImpl(ProfileManager.java:1569)
Until now, I am able to fetch logs but I want stack trace as well.
grep -i '^[[:space:]]*at' --before-context=2 SystemOut.log | grep "1/13/16 7:[1-60]"
output : [1/10/16 23:55:33:018 PST] 00000057 ServerObj E SECJ0373E: Exception message
Any idea how this can be achieved?
grep logs
grep logs
edited Jan 14 '16 at 9:03
Kevdog777
2,12213 gold badges34 silver badges61 bronze badges
2,12213 gold badges34 silver badges61 bronze badges
asked Jan 14 '16 at 8:33
Anil KumarAnil Kumar
1011 bronze badge
1011 bronze badge
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Awk with a field separator of "at" can also work. "^[" matches lines starting with the date stamp and $1 is the first field.
awk -F"at" '/^[/{print $1}' test
Based on your comment and if I understand properly what you need, the awk command should include the lines you are looking for with your grep range between 7 and 8 o'clock.
However, it sounds like you need two lists. To do this you could run the awk command on your log file and output it to another file. You could then awk/grep the second file.
awk -F"at" '/^[/{print $1}' test>> ExtractedLogs.txt
awk -F"at" '$1 ~ "07:"{print $1}' ExtractedLogs.txt>> StackTraceOnly.txt
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f255253%2ffetching-logs-from-log-file-using-grep%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Awk with a field separator of "at" can also work. "^[" matches lines starting with the date stamp and $1 is the first field.
awk -F"at" '/^[/{print $1}' test
Based on your comment and if I understand properly what you need, the awk command should include the lines you are looking for with your grep range between 7 and 8 o'clock.
However, it sounds like you need two lists. To do this you could run the awk command on your log file and output it to another file. You could then awk/grep the second file.
awk -F"at" '/^[/{print $1}' test>> ExtractedLogs.txt
awk -F"at" '$1 ~ "07:"{print $1}' ExtractedLogs.txt>> StackTraceOnly.txt
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
add a comment |
Awk with a field separator of "at" can also work. "^[" matches lines starting with the date stamp and $1 is the first field.
awk -F"at" '/^[/{print $1}' test
Based on your comment and if I understand properly what you need, the awk command should include the lines you are looking for with your grep range between 7 and 8 o'clock.
However, it sounds like you need two lists. To do this you could run the awk command on your log file and output it to another file. You could then awk/grep the second file.
awk -F"at" '/^[/{print $1}' test>> ExtractedLogs.txt
awk -F"at" '$1 ~ "07:"{print $1}' ExtractedLogs.txt>> StackTraceOnly.txt
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
add a comment |
Awk with a field separator of "at" can also work. "^[" matches lines starting with the date stamp and $1 is the first field.
awk -F"at" '/^[/{print $1}' test
Based on your comment and if I understand properly what you need, the awk command should include the lines you are looking for with your grep range between 7 and 8 o'clock.
However, it sounds like you need two lists. To do this you could run the awk command on your log file and output it to another file. You could then awk/grep the second file.
awk -F"at" '/^[/{print $1}' test>> ExtractedLogs.txt
awk -F"at" '$1 ~ "07:"{print $1}' ExtractedLogs.txt>> StackTraceOnly.txt
Awk with a field separator of "at" can also work. "^[" matches lines starting with the date stamp and $1 is the first field.
awk -F"at" '/^[/{print $1}' test
Based on your comment and if I understand properly what you need, the awk command should include the lines you are looking for with your grep range between 7 and 8 o'clock.
However, it sounds like you need two lists. To do this you could run the awk command on your log file and output it to another file. You could then awk/grep the second file.
awk -F"at" '/^[/{print $1}' test>> ExtractedLogs.txt
awk -F"at" '$1 ~ "07:"{print $1}' ExtractedLogs.txt>> StackTraceOnly.txt
edited Jan 15 '16 at 13:59
answered Jan 14 '16 at 12:24
rcjohnsonrcjohnson
8305 silver badges10 bronze badges
8305 silver badges10 bronze badges
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
add a comment |
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
grep "1/13/16 7:[1-60]" --> This is fetching based on time from 7 to 8 0'clock. So I just want to combine these two filters.
– Anil Kumar
Jan 14 '16 at 13:22
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f255253%2ffetching-logs-from-log-file-using-grep%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown